aboutsummaryrefslogtreecommitdiff
path: root/test/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'test/Modules')
-rw-r--r--test/Modules/Inputs/F.framework/Headers/F.h1
-rw-r--r--test/Modules/Inputs/F.framework/Modules/module.modulemap7
-rw-r--r--test/Modules/Inputs/F.framework/Modules/module.private.modulemap7
-rw-r--r--test/Modules/Inputs/F.framework/PrivateHeaders/NS.h19
-rw-r--r--test/Modules/Inputs/lookup-assert-protocol/Base.h3
-rw-r--r--test/Modules/Inputs/lookup-assert-protocol/Derive.h4
-rw-r--r--test/Modules/Inputs/lookup-assert-protocol/H3.h1
-rw-r--r--test/Modules/Inputs/lookup-assert-protocol/module.map4
-rw-r--r--test/Modules/Inputs/preprocess-decluse/a.h1
-rw-r--r--test/Modules/Inputs/preprocess-decluse/a.modulemap1
-rw-r--r--test/Modules/Inputs/preprocess-decluse/b.h1
-rw-r--r--test/Modules/Inputs/preprocess-decluse/b.modulemap1
-rw-r--r--test/Modules/Inputs/preprocess-decluse/main.modulemap1
-rw-r--r--test/Modules/diag-flags.cpp2
-rw-r--r--test/Modules/elaborated-type-specifier-from-hidden-module.m7
-rw-r--r--test/Modules/lookup-assert-protocol.m17
-rw-r--r--test/Modules/odr_hash.cpp68
-rw-r--r--test/Modules/preprocess-decluse.cpp18
-rw-r--r--test/Modules/redefinition-c-tagtypes.m48
-rw-r--r--test/Modules/redefinition-same-header.m10
20 files changed, 207 insertions, 14 deletions
diff --git a/test/Modules/Inputs/F.framework/Headers/F.h b/test/Modules/Inputs/F.framework/Headers/F.h
new file mode 100644
index 000000000000..4f705f00e1ac
--- /dev/null
+++ b/test/Modules/Inputs/F.framework/Headers/F.h
@@ -0,0 +1 @@
+// F.h
diff --git a/test/Modules/Inputs/F.framework/Modules/module.modulemap b/test/Modules/Inputs/F.framework/Modules/module.modulemap
new file mode 100644
index 000000000000..e414776c536b
--- /dev/null
+++ b/test/Modules/Inputs/F.framework/Modules/module.modulemap
@@ -0,0 +1,7 @@
+framework module F [extern_c] [system] {
+ umbrella header "F.h"
+ module * {
+ export *
+ }
+ export *
+}
diff --git a/test/Modules/Inputs/F.framework/Modules/module.private.modulemap b/test/Modules/Inputs/F.framework/Modules/module.private.modulemap
new file mode 100644
index 000000000000..69486a2a6410
--- /dev/null
+++ b/test/Modules/Inputs/F.framework/Modules/module.private.modulemap
@@ -0,0 +1,7 @@
+module F.Private [system] {
+ explicit module NS {
+ header "NS.h"
+ export *
+ }
+ export *
+}
diff --git a/test/Modules/Inputs/F.framework/PrivateHeaders/NS.h b/test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
new file mode 100644
index 000000000000..5e947ba90518
--- /dev/null
+++ b/test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
@@ -0,0 +1,19 @@
+struct NS {
+ int a;
+ int b;
+};
+
+enum NSE {
+ FST = 22,
+ SND = 43,
+ TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+ enum _name : _type _name; \
+ enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+ MinX = 11,
+ MinXOther = MinX,
+};
diff --git a/test/Modules/Inputs/lookup-assert-protocol/Base.h b/test/Modules/Inputs/lookup-assert-protocol/Base.h
new file mode 100644
index 000000000000..5c9506fa5cd3
--- /dev/null
+++ b/test/Modules/Inputs/lookup-assert-protocol/Base.h
@@ -0,0 +1,3 @@
+@protocol BaseProtocol
+- (void) test;
+@end
diff --git a/test/Modules/Inputs/lookup-assert-protocol/Derive.h b/test/Modules/Inputs/lookup-assert-protocol/Derive.h
new file mode 100644
index 000000000000..fdcde6158a7c
--- /dev/null
+++ b/test/Modules/Inputs/lookup-assert-protocol/Derive.h
@@ -0,0 +1,4 @@
+#include "Base.h"
+@protocol DerivedProtocol<BaseProtocol>
+- (void) test2;
+@end
diff --git a/test/Modules/Inputs/lookup-assert-protocol/H3.h b/test/Modules/Inputs/lookup-assert-protocol/H3.h
new file mode 100644
index 000000000000..3d8f878905df
--- /dev/null
+++ b/test/Modules/Inputs/lookup-assert-protocol/H3.h
@@ -0,0 +1 @@
+#include "Base.h"
diff --git a/test/Modules/Inputs/lookup-assert-protocol/module.map b/test/Modules/Inputs/lookup-assert-protocol/module.map
new file mode 100644
index 000000000000..e8a89eb095a4
--- /dev/null
+++ b/test/Modules/Inputs/lookup-assert-protocol/module.map
@@ -0,0 +1,4 @@
+module X {
+ header "H3.h"
+ export *
+}
diff --git a/test/Modules/Inputs/preprocess-decluse/a.h b/test/Modules/Inputs/preprocess-decluse/a.h
new file mode 100644
index 000000000000..17ab46c84892
--- /dev/null
+++ b/test/Modules/Inputs/preprocess-decluse/a.h
@@ -0,0 +1 @@
+// a.h
diff --git a/test/Modules/Inputs/preprocess-decluse/a.modulemap b/test/Modules/Inputs/preprocess-decluse/a.modulemap
new file mode 100644
index 000000000000..47105fe36399
--- /dev/null
+++ b/test/Modules/Inputs/preprocess-decluse/a.modulemap
@@ -0,0 +1 @@
+module A { textual header "a.h" }
diff --git a/test/Modules/Inputs/preprocess-decluse/b.h b/test/Modules/Inputs/preprocess-decluse/b.h
new file mode 100644
index 000000000000..2243de1baf9a
--- /dev/null
+++ b/test/Modules/Inputs/preprocess-decluse/b.h
@@ -0,0 +1 @@
+#include "a.h"
diff --git a/test/Modules/Inputs/preprocess-decluse/b.modulemap b/test/Modules/Inputs/preprocess-decluse/b.modulemap
new file mode 100644
index 000000000000..bd0bdf0e2e94
--- /dev/null
+++ b/test/Modules/Inputs/preprocess-decluse/b.modulemap
@@ -0,0 +1 @@
+module B { header "b.h" use A }
diff --git a/test/Modules/Inputs/preprocess-decluse/main.modulemap b/test/Modules/Inputs/preprocess-decluse/main.modulemap
new file mode 100644
index 000000000000..0392c846ce99
--- /dev/null
+++ b/test/Modules/Inputs/preprocess-decluse/main.modulemap
@@ -0,0 +1 @@
+module Main { use B }
diff --git a/test/Modules/diag-flags.cpp b/test/Modules/diag-flags.cpp
index 31d2fe4439b8..ada90d24b791 100644
--- a/test/Modules/diag-flags.cpp
+++ b/test/Modules/diag-flags.cpp
@@ -41,4 +41,4 @@ import diag_flags;
#else
// expected-no-diagnostics
#endif
-unsigned n = sizeof(Padded);
+int arr[sizeof(Padded)];
diff --git a/test/Modules/elaborated-type-specifier-from-hidden-module.m b/test/Modules/elaborated-type-specifier-from-hidden-module.m
index 0ca1c24bba00..571ccb9d95c0 100644
--- a/test/Modules/elaborated-type-specifier-from-hidden-module.m
+++ b/test/Modules/elaborated-type-specifier-from-hidden-module.m
@@ -4,12 +4,11 @@
@import ElaboratedTypeStructs.Empty; // The structs are now hidden.
struct S1 *x;
struct S2 *y;
-// FIXME: compatible definition should not be an error.
-struct S2 { int x; }; // expected-error {{redefinition}}
+struct S2 { int x; };
struct S3 *z;
// Incompatible definition.
-struct S3 { float y; }; // expected-error {{redefinition}}
-// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}}
+struct S3 { float y; }; // expected-error {{has incompatible definitions}} // expected-note {{field has name}}
+// expected-note@Inputs/elaborated-type-structs.h:3 {{field has name}}
@import ElaboratedTypeStructs.Structs;
diff --git a/test/Modules/lookup-assert-protocol.m b/test/Modules/lookup-assert-protocol.m
new file mode 100644
index 000000000000..3c093f1bf156
--- /dev/null
+++ b/test/Modules/lookup-assert-protocol.m
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/lookup-assert-protocol %s -verify
+// expected-no-diagnostics
+
+#include "Derive.h"
+#import <H3.h>
+
+__attribute__((objc_root_class))
+@interface Thing<DerivedProtocol>
+@end
+
+@implementation Thing
+- (void)test {
+}
+- (void)test2 {
+}
+@end
diff --git a/test/Modules/odr_hash.cpp b/test/Modules/odr_hash.cpp
index c94940c73eb6..6e01e989a374 100644
--- a/test/Modules/odr_hash.cpp
+++ b/test/Modules/odr_hash.cpp
@@ -968,6 +968,24 @@ S9 s9;
// expected-error@second.h:* {{'NestedNamespaceSpecifier::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'P9::I' (aka 'int')}}
// expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'O9::I' (aka 'int')}}
#endif
+
+namespace N10 {
+#if defined(FIRST)
+inline namespace A { struct X {}; }
+struct S10 {
+ A::X x;
+};
+#elif defined(SECOND)
+inline namespace B { struct X {}; }
+struct S10 {
+ B::X x;
+};
+#else
+S10 s10;
+// expected-error@second.h:* {{'NestedNamespaceSpecifier::N10::S10::x' from module 'SecondModule' is not present in definition of 'NestedNamespaceSpecifier::N10::S10' in module 'FirstModule'}}
+// expected-note@first.h:* {{declaration of 'x' does not match}}
+#endif
+}
}
namespace TemplateSpecializationType {
@@ -1070,6 +1088,40 @@ S4 s4;
// expected-error@first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}}
// expected-note@second.h:* {{declaration of 'x' does not match}}
#endif
+
+#if defined(FIRST)
+template <class T> struct U5 {};
+struct S5 {
+ U5<int> x;
+};
+#elif defined(SECOND)
+template <class T> struct U5 {};
+struct S5 {
+ U5<short> x;
+};
+#else
+S5 s5;
+// expected-error@first.h:* {{'TemplateArgument::S5::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S5' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
+#if defined(FIRST)
+template <class T> struct U6 {};
+struct S6 {
+ U6<int> x;
+ U6<short> y;
+};
+#elif defined(SECOND)
+template <class T> struct U6 {};
+struct S6 {
+ U6<short> y;
+ U6<int> x;
+};
+#else
+S6 s6;
+// expected-error@second.h:* {{'TemplateArgument::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}}
+// expected-note@first.h:* {{but in 'FirstModule' found field 'x'}}
+#endif
}
namespace TemplateTypeParmType {
@@ -1762,6 +1814,22 @@ struct S2 {
#else
S2 s2;
#endif
+
+#if defined(FIRST)
+using A3 = const int;
+using B3 = volatile A3;
+struct S3 {
+ B3 x = 1;
+};
+#elif defined(SECOND)
+using A3 = volatile const int;
+using B3 = A3;
+struct S3 {
+ B3 x = 1;
+};
+#else
+S3 s3;
+#endif
}
// Keep macros contained to one file.
diff --git a/test/Modules/preprocess-decluse.cpp b/test/Modules/preprocess-decluse.cpp
new file mode 100644
index 000000000000..5c87e0dddac2
--- /dev/null
+++ b/test/Modules/preprocess-decluse.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-strict-decluse -I%S/Inputs/preprocess-decluse \
+// RUN: -fmodule-name=B -emit-module -o %t/b.pcm \
+// RUN: -fmodule-map-file=%S/Inputs/preprocess-decluse/a.modulemap \
+// RUN: -x c++-module-map %S/Inputs/preprocess-decluse/b.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-strict-decluse -I%S/Inputs/preprocess-decluse \
+// RUN: -fmodule-map-file=%S/Inputs/preprocess-decluse/main.modulemap \
+// RUN: -fmodule-file=%t/b.pcm -fmodule-name=Main %s -verify
+// RUN: %clang_cc1 -fmodules -fmodules-strict-decluse -I%S/Inputs/preprocess-decluse \
+// RUN: -fmodule-map-file=%S/Inputs/preprocess-decluse/main.modulemap \
+// RUN: -fmodule-file=%t/b.pcm -fmodule-name=Main %s \
+// RUN: -E -frewrite-imports -o %t/rewrite.ii
+// RUN: %clang_cc1 -fmodules -fmodules-strict-decluse -I%S/Inputs/preprocess-decluse \
+// RUN: -fmodule-map-file=%S/Inputs/preprocess-decluse/main.modulemap \
+// RUN: -fmodule-name=Main %t/rewrite.ii -verify
+
+// expected-no-diagnostics
+#include "b.h"
diff --git a/test/Modules/redefinition-c-tagtypes.m b/test/Modules/redefinition-c-tagtypes.m
new file mode 100644
index 000000000000..a01f11bd74c8
--- /dev/null
+++ b/test/Modules/redefinition-c-tagtypes.m
@@ -0,0 +1,48 @@
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN: -fimplicit-module-maps -F%S/Inputs -verify
+// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \
+// RUN: -fimplicit-module-maps -F%S/Inputs -DCHANGE_TAGS -verify
+#include "F/F.h"
+
+#ifndef CHANGE_TAGS
+// expected-no-diagnostics
+#endif
+
+struct NS {
+ int a;
+#ifndef CHANGE_TAGS
+ int b;
+#else
+ int c; // expected-note {{field has name 'c' here}}
+ // expected-error@redefinition-c-tagtypes.m:12 {{type 'struct NS' has incompatible definitions}}
+ // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:3 {{field has name 'b' here}}
+#endif
+};
+
+enum NSE {
+ FST = 22,
+#ifndef CHANGE_TAGS
+ SND = 43,
+#else
+ SND = 44, // expected-note {{enumerator 'SND' with value 44 here}}
+ // expected-error@redefinition-c-tagtypes.m:23 {{type 'enum NSE' has incompatible definitions}}
+ // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:8 {{enumerator 'SND' with value 43 here}}
+#endif
+ TRD = 55
+};
+
+#define NS_ENUM(_type, _name) \
+ enum _name : _type _name; \
+ enum _name : _type
+
+typedef NS_ENUM(int, NSMyEnum) {
+ MinX = 11,
+#ifndef CHANGE_TAGS
+ MinXOther = MinX,
+#else
+ MinXOther = TRD, // expected-note {{enumerator 'MinXOther' with value 55 here}}
+ // expected-error@redefinition-c-tagtypes.m:39 {{type 'enum NSMyEnum' has incompatible definitions}}
+ // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:18 {{enumerator 'MinXOther' with value 11 here}}
+#endif
+};
diff --git a/test/Modules/redefinition-same-header.m b/test/Modules/redefinition-same-header.m
index f1c6cbbcaa2e..8c180f643225 100644
--- a/test/Modules/redefinition-same-header.m
+++ b/test/Modules/redefinition-same-header.m
@@ -6,15 +6,7 @@
// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
// expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
+// expected-warning@Inputs/SameHeader/C.h:9 {{typedef requires a name}}
-// expected-error@Inputs/SameHeader/C.h:5 {{redefinition of 'aaa'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
-// expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
-
-// expected-error@Inputs/SameHeader/C.h:9 {{redefinition of 'fd_set'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple times, additional include site in header from module 'X.B'}}
-// expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included multiple times, additional include site here}}
#include "A.h" // maps to a modular
#include "C.h" // textual include