1 // Clear and create directories
5 // RUN: mkdir %t/Inputs
7 // Build first header file
8 // RUN: echo "#define FIRST" >> %t/Inputs/first.h
9 // RUN: cat %s >> %t/Inputs/first.h
11 // Build second header file
12 // RUN: echo "#define SECOND" >> %t/Inputs/second.h
13 // RUN: cat %s >> %t/Inputs/second.h
15 // Test that each header can compile
16 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++1z %t/Inputs/first.h
17 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++1z %t/Inputs/second.h
19 // Build module map file
20 // RUN: echo "module FirstModule {" >> %t/Inputs/module.map
21 // RUN: echo " header \"first.h\"" >> %t/Inputs/module.map
22 // RUN: echo "}" >> %t/Inputs/module.map
23 // RUN: echo "module SecondModule {" >> %t/Inputs/module.map
24 // RUN: echo " header \"second.h\"" >> %t/Inputs/module.map
25 // RUN: echo "}" >> %t/Inputs/module.map
28 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++1z
30 #if !defined(FIRST) && !defined(SECOND)
37 #define ACCESS public:
39 #define ACCESS private:
42 namespace AccessSpecifiers {
52 // expected-error@second.h:* {{'AccessSpecifiers::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
53 // expected-note@first.h:* {{but in 'FirstModule' found end of class}}
66 // expected-error@second.h:* {{'AccessSpecifiers::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found protected access specifier}}
67 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
75 #if defined(FIRST) || defined(SECOND)
83 #if defined(FIRST) || defined(SECOND)
90 // expected-error@second.h:* {{'AccessSpecifiers::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
91 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
95 } // namespace AccessSpecifiers
97 namespace StaticAssert {
100 static_assert(1 == 1, "First");
102 #elif defined(SECOND)
104 static_assert(1 == 1, "Second");
108 // expected-error@second.h:* {{'StaticAssert::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with message}}
109 // expected-note@first.h:* {{but in 'FirstModule' found static assert with different message}}
114 static_assert(2 == 2, "Message");
116 #elif defined(SECOND)
118 static_assert(2 == 2);
122 // expected-error@second.h:* {{'StaticAssert::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with no message}}
123 // expected-note@first.h:* {{but in 'FirstModule' found static assert with message}}
128 static_assert(3 == 3, "Message");
130 #elif defined(SECOND)
132 static_assert(3 != 4, "Message");
136 // expected-error@second.h:* {{'StaticAssert::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with condition}}
137 // expected-note@first.h:* {{but in 'FirstModule' found static assert with different condition}}
142 static_assert(4 == 4, "Message");
144 #elif defined(SECOND)
150 // expected-error@second.h:* {{'StaticAssert::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
151 // expected-note@first.h:* {{but in 'FirstModule' found static assert}}
155 static_assert(4 == 4, "Message"); \
156 static_assert(5 == 5);
158 #if defined(FIRST) || defined(SECOND)
166 #if defined(FIRST) || defined(SECOND)
173 // expected-error@second.h:* {{'StaticAssert::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
174 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
177 } // namespace StaticAssert
186 #elif defined(SECOND)
193 // expected-error@second.h:* {{'Field::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}}
194 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
202 #elif defined(SECOND)
209 // expected-error@second.h:* {{'Field::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}}
210 // expected-note@first.h:* {{but in 'FirstModule' found field 'x'}}
217 #elif defined(SECOND)
223 // expected-error@first.h:* {{'Field::S3::x' from module 'FirstModule' is not present in definition of 'Field::S3' in module 'SecondModule'}}
224 // expected-note@second.h:* {{declaration of 'x' does not match}}
236 #elif defined(SECOND)
247 // expected-error@second.h:* {{'Field::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'Field::B' (aka 'int')}}
248 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'Field::A' (aka 'int')}}
251 // expected-error@second.h:* {{'Field::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'int'}}
252 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'Field::A' (aka 'int')}}
259 #elif defined(SECOND)
265 // expected-error@second.h:* {{'Field::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found bitfield 'x'}}
266 // expected-note@first.h:* {{but in 'FirstModule' found non-bitfield 'x'}}
273 #elif defined(SECOND)
279 // expected-error@second.h:* {{'Field::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found bitfield 'x' with one width expression}}
280 // expected-note@first.h:* {{but in 'FirstModule' found bitfield 'x' with different width expression}}
287 #elif defined(SECOND)
293 // expected-error@second.h:* {{'Field::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found bitfield 'x' with one width expression}}
294 // expected-note@first.h:* {{but in 'FirstModule' found bitfield 'x' with different width expression}}
301 #elif defined(SECOND)
307 // expected-error@second.h:* {{'Field::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found non-mutable field 'x'}}
308 // expected-note@first.h:* {{but in 'FirstModule' found mutable field 'x'}}
315 #elif defined(SECOND)
321 // expected-error@second.h:* {{'Field::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with no initalizer}}
322 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with an initializer}}
329 #elif defined(SECOND)
335 // expected-error@second.h:* {{'Field::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with an initializer}}
336 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}}
343 #elif defined(SECOND)
349 // expected-error@first.h:* {{'Field::S12::x' from module 'FirstModule' is not present in definition of 'Field::S12' in module 'SecondModule'}}
350 // expected-note@second.h:* {{declaration of 'x' does not match}}
357 #elif defined(SECOND)
363 // expected-error@first.h:* {{'Field::S13::x' from module 'FirstModule' is not present in definition of 'Field::S13' in module 'SecondModule'}}
364 // expected-note@second.h:* {{declaration of 'x' does not match}}
370 unsigned c : 1 + 2; \
375 #if defined(FIRST) || defined(SECOND)
379 #if defined(FIRST) || defined(SECOND)
387 #if defined(FIRST) || defined(SECOND)
394 // expected-error@second.h:* {{'Field::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
395 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
405 #elif defined(SECOND)
412 // expected-error@second.h:* {{'Method::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
413 // expected-note@first.h:* {{but in 'FirstModule' found method}}
421 #elif defined(SECOND)
428 // expected-error@second.h:* {{'Method::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'B'}}
429 // expected-note@first.h:* {{but in 'FirstModule' found method 'A'}}
437 #elif defined(SECOND)
444 // expected-error@second.h:* {{'Method::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not static}}
445 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is static}}
453 #elif defined(SECOND)
460 // expected-error@second.h:* {{'Method::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not virtual}}
461 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is virtual}}
466 virtual void A() = 0;
469 #elif defined(SECOND)
472 virtual void B() = 0;
476 // expected-error@second.h:* {{'Method::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is virtual}}
477 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is pure virtual}}
484 #elif defined(SECOND)
490 // expected-error@second.h:* {{'Method::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not inline}}
491 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is inline}}
499 #elif defined(SECOND)
506 // expected-error@second.h:* {{'Method::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not volatile}}
507 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is volatile}}
515 #elif defined(SECOND)
522 // expected-error@second.h:* {{'Method::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not const}}
523 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is const}}
529 void A(int x, int y) {}
531 #elif defined(SECOND)
533 void A(int x, int y) {}
538 // expected-error@second.h:* {{'Method::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' that has 2 parameters}}
539 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' that has 1 parameter}}
547 #elif defined(SECOND)
554 // expected-error@second.h:* {{'Method::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter of type 'float'}}
555 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int'}}
562 #elif defined(SECOND)
568 // expected-error@second.h:* {{'Method::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter named 'y'}}
569 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter named 'x'}}
576 #elif defined(SECOND)
582 // expected-error@second.h:* {{'Method::S12' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter without a default argument}}
583 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a default argument}}
588 void A(int x = 1 + 0);
590 #elif defined(SECOND)
596 // expected-error@second.h:* {{'Method::S13' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter with a default argument}}
597 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a different default argument}}
604 #elif defined(SECOND)
610 // expected-error@second.h:* {{'Method::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [3]'}}
611 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [2]'}}
616 int A() { return 0; }
618 #elif defined(SECOND)
620 long A() { return 0; }
624 // expected-error@first.h:* {{'Method::S15::A' from module 'FirstModule' is not present in definition of 'Method::S15' in module 'SecondModule'}}
625 // expected-note@second.h:* {{declaration of 'A' does not match}}
632 virtual void D() = 0; \
637 void I(int x = 5 + 5); \
642 #if defined(FIRST) || defined(SECOND)
650 #if defined(FIRST) || defined(SECOND)
657 // expected-error@second.h:* {{'Method::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
658 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
661 } // namespace Method
663 namespace MethodBody {
666 int A() { return 0; }
668 #elif defined(SECOND)
670 int A() { return 0; }
678 int BothBodies() { return 0; }
680 #elif defined(SECOND)
682 int BothBodies() { return 1; }
686 // expected-error@first.h:* {{'MethodBody::S2' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'BothBodies' with body}}
687 // expected-note@second.h:* {{but in 'SecondModule' found method 'BothBodies' with different body}}
692 int FirstBody() { return 0; }
694 #elif defined(SECOND)
700 // expected-error@first.h:* {{'MethodBody::S3' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstBody' with body}}
701 // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstBody' with no body}}
708 #elif defined(SECOND)
710 int SecondBody() { return 0; }
714 // expected-error@first.h:* {{'MethodBody::S4' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'SecondBody' with no body}}
715 // expected-note@second.h:* {{but in 'SecondModule' found method 'SecondBody' with body}}
720 int FirstBodySecondOutOfLine() { return 0; }
722 #elif defined(SECOND)
724 int FirstBodySecondOutOfLine();
726 int S5::FirstBodySecondOutOfLine() { return 0; }
729 // expected-error@second.h:* {{'MethodBody::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'FirstBodySecondOutOfLine' with no body}}
730 // expected-note@first.h:* {{but in 'FirstModule' found method 'FirstBodySecondOutOfLine' with body}}
735 int FirstOutOfLineSecondBody();
737 int S6::FirstOutOfLineSecondBody() { return 0; }
738 #elif defined(SECOND)
740 int FirstOutOfLineSecondBody() { return 0; }
744 // expected-error@first.h:* {{'MethodBody::S6' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstOutOfLineSecondBody' with no body}}
745 // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstOutOfLineSecondBody' with body}}
752 int S7::BothOutOfLine() { return 1; }
753 #elif defined(SECOND)
757 int S7::BothOutOfLine() { return 0; }
760 // expected-error@second.h:* {{'MethodBody::S7::BothOutOfLine' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
761 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
766 int FirstBodySecondOutOfLine() { return 0; }
768 #elif defined(SECOND)
770 int FirstBodySecondOutOfLine();
772 int S8::FirstBodySecondOutOfLine() { return 1; }
775 // expected-error@second.h:* {{'MethodBody::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'FirstBodySecondOutOfLine' with no body}}
776 // expected-note@first.h:* {{but in 'FirstModule' found method 'FirstBodySecondOutOfLine' with body}}
781 int FirstOutOfLineSecondBody();
783 int S9::FirstOutOfLineSecondBody() { return 1; }
784 #elif defined(SECOND)
786 int FirstOutOfLineSecondBody() { return 0; }
790 // expected-error@first.h:* {{'MethodBody::S9' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstOutOfLineSecondBody' with no body}}
791 // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstOutOfLineSecondBody' with body}}
799 #elif defined(SECOND)
806 // expected-error@first.h:* {{'MethodBody::S10' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is deleted}}
807 // expected-note@second.h:* {{but in 'SecondModule' found constructor is not deleted}}
814 #elif defined(SECOND)
820 // expected-error@first.h:* {{'MethodBody::S11' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is defaulted}}
821 // expected-note@second.h:* {{but in 'SecondModule' found constructor is not defaulted}}
824 #define DECLS(CLASSNAME) \
825 CLASSNAME() = default; \
826 ~CLASSNAME() = delete; \
828 void B() { return; }; \
832 #define OUTOFLINEDEFS(CLASSNAME) \
833 void CLASSNAME::C() {} \
834 void CLASSNAME::D() { return; }
836 #if defined(FIRST) || defined(SECOND)
840 OUTOFLINEDEFS(Valid1)
845 #if defined(FIRST) || defined(SECOND)
850 OUTOFLINEDEFS(Invalid1)
853 // expected-error@first.h:* {{'MethodBody::Invalid1' has different definitions in different modules; first difference is definition in module 'FirstModule' found public access specifier}}
854 // expected-note@second.h:* {{but in 'SecondModule' found private access specifier}}
857 } // namespace MethodBody
859 namespace Constructor {
865 #elif defined(SECOND)
872 // expected-error@second.h:* {{'Constructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'foo'}}
873 // expected-note@first.h:* {{but in 'FirstModule' found constructor}}
881 #elif defined(SECOND)
888 // expected-error@second.h:* {{'Constructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor that has 2 parameters}}
889 // expected-note@first.h:* {{but in 'FirstModule' found constructor that has 1 parameter}}
892 #define DECLS(CLASS) \
897 #if defined(FIRST) || defined(SECOND)
905 #if defined(FIRST) || defined(SECOND)
912 // expected-error@second.h:* {{'Constructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
913 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
916 } // namespace Constructor
918 namespace Destructor {
924 #elif defined(SECOND)
931 // expected-error@second.h:* {{'Destructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor}}
932 // expected-note@first.h:* {{but in 'FirstModule' found destructor}}
940 #elif defined(SECOND)
943 virtual void foo() {}
947 // expected-error@second.h:* {{'Destructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found destructor is not virtual}}
948 // expected-note@first.h:* {{but in 'FirstModule' found destructor is virtual}}
951 #if defined(FIRST) || defined(SECOND)
959 #if defined(FIRST) || defined(SECOND)
966 // expected-error@second.h:* {{'Destructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
967 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
970 #if defined(FIRST) || defined(SECOND)
978 #if defined(FIRST) || defined(SECOND)
985 // expected-error@second.h:* {{'Destructor::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
986 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
988 } // namespace Destructor
995 #elif defined(SECOND)
1001 // expected-error@first.h:* {{'TypeDef::S1::a' from module 'FirstModule' is not present in definition of 'TypeDef::S1' in module 'SecondModule'}}
1002 // expected-note@second.h:* {{declaration of 'a' does not match}}
1009 #elif defined(SECOND)
1015 // expected-error@first.h:* {{'TypeDef::S2::a' from module 'FirstModule' is not present in definition of 'TypeDef::S2' in module 'SecondModule'}}
1016 // expected-note@second.h:* {{definition has no member 'a'}}
1024 #elif defined(SECOND)
1031 // expected-error@first.h:* {{'TypeDef::S3::a' from module 'FirstModule' is not present in definition of 'TypeDef::S3' in module 'SecondModule'}}
1032 // expected-note@second.h:* {{declaration of 'a' does not match}}
1040 #elif defined(SECOND)
1047 // expected-error@second.h:* {{'TypeDef::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found typedef name 'b'}}
1048 // expected-note@first.h:* {{but in 'FirstModule' found typedef name 'a'}}
1057 #elif defined(SECOND)
1065 // expected-error@second.h:* {{'TypeDef::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}}
1066 // expected-note@first.h:* {{but in 'FirstModule' found typedef}}
1075 #elif defined(SECOND)
1082 // expected-error@second.h:* {{'TypeDef::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found typedef 'b' with underlying type 'float'}}
1083 // expected-note@first.h:* {{but in 'FirstModule' found typedef 'b' with different underlying type 'TypeDef::F' (aka 'float')}}
1091 #if defined(FIRST) || defined(SECOND)
1095 #if defined(FIRST) || defined(SECOND)
1103 #if defined(FIRST) || defined(SECOND)
1110 // expected-error@second.h:* {{'TypeDef::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1111 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1114 } // namespace TypeDef
1121 #elif defined(SECOND)
1127 // expected-error@first.h:* {{'Using::S1::a' from module 'FirstModule' is not present in definition of 'Using::S1' in module 'SecondModule'}}
1128 // expected-note@second.h:* {{declaration of 'a' does not match}}
1135 #elif defined(SECOND)
1141 // expected-error@first.h:* {{'Using::S2::a' from module 'FirstModule' is not present in definition of 'Using::S2' in module 'SecondModule'}}
1142 // expected-note@second.h:* {{definition has no member 'a'}}
1150 #elif defined(SECOND)
1157 // expected-error@first.h:* {{'Using::S3::a' from module 'FirstModule' is not present in definition of 'Using::S3' in module 'SecondModule'}}
1158 // expected-note@second.h:* {{declaration of 'a' does not match}}
1166 #elif defined(SECOND)
1173 // expected-error@second.h:* {{'Using::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias name 'b'}}
1174 // expected-note@first.h:* {{but in 'FirstModule' found type alias name 'a'}}
1183 #elif defined(SECOND)
1191 // expected-error@second.h:* {{'Using::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}}
1192 // expected-note@first.h:* {{but in 'FirstModule' found type alias}}
1201 #elif defined(SECOND)
1208 // expected-error@second.h:* {{'Using::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'b' with underlying type 'float'}}
1209 // expected-note@first.h:* {{but in 'FirstModule' found type alias 'b' with different underlying type 'Using::F' (aka 'float')}}
1212 #if defined(FIRST) || defined(SECOND)
1221 #if defined(FIRST) || defined(SECOND)
1229 #if defined(FIRST) || defined(SECOND)
1236 // expected-error@second.h:* {{'Using::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1237 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1240 } // namespace Using
1242 namespace RecordType {
1248 #elif defined(SECOND)
1255 // expected-error@first.h:* {{'RecordType::S1::x' from module 'FirstModule' is not present in definition of 'RecordType::S1' in module 'SecondModule'}}
1256 // expected-note@second.h:* {{declaration of 'x' does not match}}
1262 #if defined(FIRST) || defined(SECOND)
1266 #if defined(FIRST) || defined(SECOND)
1274 #if defined(FIRST) || defined(SECOND)
1281 // expected-error@second.h:* {{'RecordType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1282 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1285 } // namespace RecordType
1287 namespace DependentType {
1291 typename T::typeA x;
1293 #elif defined(SECOND)
1296 typename T::typeB x;
1301 // expected-error@first.h:* {{'DependentType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T>' in module 'SecondModule'}}
1302 // expected-note@second.h:* {{declaration of 'x' does not match}}
1306 typename T::typeA x;
1308 #if defined(FIRST) || defined(SECOND)
1315 using V1 = Valid1<T>;
1318 #if defined(FIRST) || defined(SECOND)
1326 using I1 = Invalid1<T>;
1327 // expected-error@second.h:* {{'DependentType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1328 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1331 } // namespace DependentType
1333 namespace ElaboratedType {
1335 namespace N1 { using type = double; }
1339 #elif defined(SECOND)
1340 namespace N1 { using type = int; }
1346 // expected-error@first.h:* {{'ElaboratedType::S1::x' from module 'FirstModule' is not present in definition of 'ElaboratedType::S1' in module 'SecondModule'}}
1347 // expected-note@second.h:* {{declaration of 'x' does not match}}
1353 #if defined(FIRST) || defined(SECOND)
1354 namespace NS { using type = float; }
1357 #if defined(FIRST) || defined(SECOND)
1365 #if defined(FIRST) || defined(SECOND)
1372 // expected-error@second.h:* {{'ElaboratedType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1373 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1376 } // namespace ElaboratedType
1384 #elif defined(SECOND)
1391 // expected-error@first.h:* {{'Enum::S1::x' from module 'FirstModule' is not present in definition of 'Enum::S1' in module 'SecondModule'}}
1392 // expected-note@second.h:* {{declaration of 'x' does not match}}
1398 #if defined(FIRST) || defined(SECOND)
1402 #if defined(FIRST) || defined(SECOND)
1410 #if defined(FIRST) || defined(SECOND)
1417 // expected-error@second.h:* {{'Enum::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1418 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1423 namespace NestedNamespaceSpecifier {
1432 # elif defined(SECOND)
1440 LevelB1::LevelC1::Type x;
1444 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'LevelB1::LevelC1::Type' (aka 'int')}}
1445 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA1::Type' (aka 'int')}}
1449 namespace LevelA2 { using Type = int; }
1453 # elif defined(SECOND)
1459 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'int'}}
1460 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA2::Type' (aka 'int')}}
1463 namespace LevelA3 { using Type = int; }
1464 namespace LevelB3 { using Type = int; }
1469 # elif defined(SECOND)
1475 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'LevelB3::Type' (aka 'int')}}
1476 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA3::Type' (aka 'int')}}
1480 struct TA4 { using Type = int; };
1484 # elif defined(SECOND)
1485 struct TB4 { using Type = int; };
1491 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'TB4::Type' (aka 'int')}}
1492 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'TA4::Type' (aka 'int')}}
1496 struct T5 { using Type = int; };
1500 # elif defined(SECOND)
1501 namespace T5 { using Type = int; };
1507 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'T5::Type' (aka 'int')}}
1508 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'T5::Type' (aka 'int')}}
1512 namespace N6 {using I = int;}
1514 NestedNamespaceSpecifier::N6::I x;
1516 # elif defined(SECOND)
1519 ::NestedNamespaceSpecifier::I x;
1523 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type '::NestedNamespaceSpecifier::I' (aka 'int')}}
1524 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'NestedNamespaceSpecifier::N6::I' (aka 'int')}}
1528 template <class T, class U>
1530 typename T::type *x = {};
1531 int z = x->T::foo();
1533 #elif defined(SECOND)
1534 template <class T, class U>
1536 typename T::type *x = {};
1537 int z = x->U::foo();
1540 template <class T, class U>
1541 using U7 = S7<T, U>;
1542 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'z' with an initializer}}
1543 // expected-note@first.h:* {{but in 'FirstModule' found field 'z' with a different initializer}}
1549 int x = T::template X<int>::value;
1551 #elif defined(SECOND)
1554 int x = T::template Y<int>::value;
1559 // expected-error@second.h:* {{'NestedNamespaceSpecifier::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with an initializer}}
1560 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}}
1564 namespace N9 { using I = int; }
1569 #elif defined(SECOND)
1570 namespace N9 { using I = int; }
1577 // 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')}}
1578 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'O9::I' (aka 'int')}}
1583 inline namespace A { struct X {}; }
1587 #elif defined(SECOND)
1588 inline namespace B { struct X {}; }
1594 // expected-error@second.h:* {{'NestedNamespaceSpecifier::N10::S10::x' from module 'SecondModule' is not present in definition of 'NestedNamespaceSpecifier::N10::S10' in module 'FirstModule'}}
1595 // expected-note@first.h:* {{declaration of 'x' does not match}}
1605 #if defined(FIRST) || defined(SECOND)
1609 using Type = double;
1613 namespace NS3 = NS1;
1616 #if defined(FIRST) || defined(SECOND)
1624 #if defined(FIRST) || defined(SECOND)
1631 // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1632 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1637 typename T::type *x = {}; \
1638 int y = x->T::foo(); \
1639 int z = U::template X<int>::value;
1641 #if defined(FIRST) || defined(SECOND)
1642 template <class T, class U>
1647 template <class T, class U>
1648 using V2 = Valid2<T, U>;
1651 #if defined(FIRST) || defined(SECOND)
1652 template <class T, class U>
1658 template <class T, class U>
1659 using I2 = Invalid2<T, U>;
1660 // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1661 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1664 } // namespace NestedNamespaceSpecifier
1666 namespace TemplateSpecializationType {
1668 template <class T1> struct U1 {};
1672 #elif defined(SECOND)
1673 template <class T1, class T2> struct U1 {};
1679 // expected-error@first.h:* {{'TemplateSpecializationType::S1::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S1' in module 'SecondModule'}}
1680 // expected-note@second.h:* {{declaration of 'u' does not match}}
1684 template <class T1> struct U2 {};
1688 #elif defined(SECOND)
1689 template <class T1> struct V1 {};
1695 // expected-error@first.h:* {{'TemplateSpecializationType::S2::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S2' in module 'SecondModule'}}
1696 // expected-note@second.h:* {{declaration of 'u' does not match}}
1700 OneTemplateArg<int> x; \
1701 OneTemplateArg<double> y; \
1702 OneTemplateArg<char *> z; \
1703 TwoTemplateArgs<int, int> a; \
1704 TwoTemplateArgs<double, float> b; \
1705 TwoTemplateArgs<short *, char> c;
1707 #if defined(FIRST) || defined(SECOND)
1708 template <class T> struct OneTemplateArg {};
1709 template <class T, class U> struct TwoTemplateArgs {};
1712 #if defined(FIRST) || defined(SECOND)
1720 #if defined(FIRST) || defined(SECOND)
1727 // expected-error@second.h:* {{'TemplateSpecializationType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1728 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1731 } // namespace TemplateSpecializationType
1733 namespace TemplateArgument {
1735 template <class> struct U1{};
1739 #elif defined(SECOND)
1740 template <int> struct U1{};
1746 // expected-error@first.h:* {{'TemplateArgument::S1::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 'SecondModule'}}
1747 // expected-note@second.h:* {{declaration of 'x' does not match}}
1751 template <int> struct U2{};
1755 #elif defined(SECOND)
1756 template <int> struct U2{};
1762 // expected-error@second.h:* {{'TemplateArgument::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'T' with underlying type 'U2<(2)>'}}
1763 // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U2<2>'}}
1767 template <int> struct U3{};
1771 #elif defined(SECOND)
1772 template <int> struct U3{};
1774 using T = U3<1 + 1>;
1778 // expected-error@second.h:* {{'TemplateArgument::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'T' with underlying type 'U3<1 + 1>'}}
1779 // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U3<2>'}}
1783 template<class> struct T4a {};
1784 template <template <class> class T> struct U4 {};
1788 #elif defined(SECOND)
1789 template<class> struct T4b {};
1790 template <template <class> class T> struct U4 {};
1796 // expected-error@first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}}
1797 // expected-note@second.h:* {{declaration of 'x' does not match}}
1801 template <class T> struct U5 {};
1805 #elif defined(SECOND)
1806 template <class T> struct U5 {};
1812 // expected-error@first.h:* {{'TemplateArgument::S5::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S5' in module 'SecondModule'}}
1813 // expected-note@second.h:* {{declaration of 'x' does not match}}
1817 template <class T> struct U6 {};
1822 #elif defined(SECOND)
1823 template <class T> struct U6 {};
1830 // expected-error@second.h:* {{'TemplateArgument::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}}
1831 // expected-note@first.h:* {{but in 'FirstModule' found field 'x'}}
1836 template<int> void run() {}
1837 template<> void run<1>() {}
1839 #elif defined(SECOND)
1841 template<int> void run() {}
1846 // expected-error@second.h:* {{'TemplateArgument::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with no template arguments}}
1847 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with template arguments}}
1853 template<int&> void run() {}
1854 template<int&, int&> void run() {}
1855 template<> void run<a>() {}
1857 #elif defined(SECOND)
1860 template<int&> void run() {}
1861 template<int&, int&> void run() {}
1862 template<> void run<a, b>() {}
1866 // expected-error@second.h:* {{'TemplateArgument::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 2 template arguments}}
1867 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 1 template argument}}
1873 template<int&> void run() {}
1874 template<> void run<a>() {}
1876 #elif defined(SECOND)
1879 template<int&> void run() {}
1880 template<> void run<b>() {}
1884 // expected-error@second.h:* {{'TemplateArgument::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 'b' for 1st template argument}}
1885 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 'a' for 1st template argument}}
1891 template<int, int&...> void run() {}
1892 template<> void run<1, a>() {}
1894 #elif defined(SECOND)
1897 template<int, int&...> void run() {}
1898 template<> void run<1, b>() {}
1902 // expected-error@second.h:* {{'TemplateArgument::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 'b' for 2nd template argument}}
1903 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 'a' for 2nd template argument}}
1909 template<int, int&...> void run() {}
1910 template<> void run<1, a>() {}
1912 #elif defined(SECOND)
1915 template<int, int&...> void run() {}
1916 template<> void run<1, a, a>() {}
1920 // expected-error@second.h:* {{'TemplateArgument::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 3 template arguments}}
1921 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 2 template arguments}}
1927 using c = OneClass<float>; \
1928 using d = OneInt<2>; \
1929 using e = OneInt<2 + 2>; \
1930 OneTemplateClass<OneClass> f; \
1931 OneTemplateInt<OneInt> g; \
1932 static int i1, i2; \
1934 void Function() {} \
1935 template <int &, int &> \
1936 void Function() {} \
1938 void Function<i1>() {} \
1940 void Function<i2>() {} \
1942 void Function<i1, i2>() {} \
1944 void Function<i2, i1>() {}
1946 #if defined(FIRST) || defined(SECOND)
1947 template <class> struct OneClass{};
1948 template <int> struct OneInt{};
1949 template <template <class> class> struct OneTemplateClass{};
1950 template <template <int> class> struct OneTemplateInt{};
1953 #if defined(FIRST) || defined(SECOND)
1961 #if defined(FIRST) || defined(SECOND)
1968 // expected-error@second.h:* {{'TemplateArgument::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1969 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1972 } // namespace TemplateArgument
1974 namespace TemplateTypeParmType {
1976 template <class T1, class T2>
1980 #elif defined(SECOND)
1981 template <class T1, class T2>
1986 using TemplateTypeParmType::S1;
1987 // expected-error@first.h:* {{'TemplateTypeParmType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T1, T2>' in module 'SecondModule'}}
1988 // expected-note@second.h:* {{declaration of 'x' does not match}}
1992 template <int ...Ts>
1994 template <int T, int U>
1996 typedef U2<U, T> type;
1999 #elif defined(SECOND)
2000 template <int ...Ts>
2002 template <int T, int U>
2004 typedef U2<T, U> type;
2008 using TemplateTypeParmType::S2;
2009 // expected-error@first.h:* {{'TemplateTypeParmType::S2::x' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}}
2010 // expected-note@second.h:* {{declaration of 'x' does not match}}
2011 // expected-error@first.h:* {{'TemplateTypeParmType::S2::type' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}}
2012 // expected-note@second.h:* {{declaration of 'type' does not match}}
2018 ParameterPack<T> a; \
2019 ParameterPack<T, U> b; \
2020 ParameterPack<U> c; \
2021 ParameterPack<U, T> d;
2023 #if defined(FIRST) || defined(SECOND)
2024 template <class ...Ts> struct ParameterPack {};
2027 #if defined(FIRST) || defined(SECOND)
2028 template <class T, class U>
2033 using TemplateTypeParmType::Valid1;
2036 #if defined(FIRST) || defined(SECOND)
2037 template <class T, class U>
2043 using TemplateTypeParmType::Invalid1;
2044 // expected-error@second.h:* {{'TemplateTypeParmType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2045 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2048 } // namespace TemplateTypeParmType
2056 #elif defined(SECOND)
2063 // expected-error@second.h:* {{'VarDecl::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member with name 'y'}}
2064 // expected-note@first.h:* {{but in 'FirstModule' found data member with name 'x'}}
2071 #elif defined(SECOND)
2078 // expected-error@second.h:* {{'VarDecl::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' with type 'VarDecl::I' (aka 'int')}}
2079 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with different type 'int'}}
2084 static const int x = 1;
2086 #elif defined(SECOND)
2092 // expected-error@second.h:* {{'VarDecl::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' with an initializer}}
2093 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' without an initializer}}
2098 static const int x = 1;
2100 #elif defined(SECOND)
2102 static const int x = 2;
2106 // expected-error@second.h:* {{'VarDecl::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' with an initializer}}
2107 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with a different initializer}}
2112 static const int x = 1;
2114 #elif defined(SECOND)
2116 static constexpr int x = 1;
2120 // expected-error@second.h:* {{'VarDecl::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' is not constexpr}}
2121 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' is constexpr}}
2126 static const int x = 1;
2128 #elif defined(SECOND)
2130 static const int y = 1;
2134 // expected-error@first.h:* {{'VarDecl::S6::x' from module 'FirstModule' is not present in definition of 'VarDecl::S6' in module 'SecondModule'}}
2135 // expected-note@second.h:* {{definition has no member 'x'}}
2140 static const int x = 1;
2142 #elif defined(SECOND)
2144 static const unsigned x = 1;
2148 // expected-error@first.h:* {{'VarDecl::S7::x' from module 'FirstModule' is not present in definition of 'VarDecl::S7' in module 'SecondModule'}}
2149 // expected-note@second.h:* {{declaration of 'x' does not match}}
2155 static const int x = 1;
2157 #elif defined(SECOND)
2159 static const int x = 1;
2164 // expected-error@second.h:* {{'VarDecl::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member}}
2165 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2170 static const int x = 1;
2172 #elif defined(SECOND)
2178 // expected-error@first.h:* {{'VarDecl::S9::x' from module 'FirstModule' is not present in definition of 'VarDecl::S9' in module 'SecondModule'}}
2179 // expected-note@second.h:* {{declaration of 'x' does not match}}
2185 static const int c = 1; \
2186 static constexpr int d = 5;
2188 #if defined(FIRST) || defined(SECOND)
2192 #if defined(FIRST) || defined(SECOND)
2200 #if defined(FIRST) || defined(SECOND)
2207 // expected-error@second.h:* {{'VarDecl::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2208 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2211 } // namespace VarDecl
2219 #elif defined(SECOND)
2226 // expected-error@second.h:* {{'Friend::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'Friend::T1'}}
2227 // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T1'}}
2235 #elif defined(SECOND)
2242 // expected-error@second.h:* {{'Friend::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'struct T2'}}
2243 // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T2'}}
2251 #elif defined(SECOND)
2258 // expected-error@second.h:* {{'Friend::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'Friend::T3'}}
2259 // expected-note@first.h:* {{but in 'FirstModule' found friend 'const Friend::T3'}}
2267 #elif defined(SECOND)
2273 // expected-error@second.h:* {{'Friend::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function}}
2274 // expected-note@first.h:* {{but in 'FirstModule' found friend class}}
2281 #elif defined(SECOND)
2287 // expected-error@second.h:* {{'Friend::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function 'T5b'}}
2288 // expected-note@first.h:* {{but in 'FirstModule' found friend function 'T5a'}}
2292 friend class FriendA; \
2293 friend struct FriendB; \
2295 friend const FriendD; \
2296 friend void Function();
2298 #if defined(FIRST) || defined(SECOND)
2305 #if defined(FIRST) || defined(SECOND)
2313 #if defined(FIRST) || defined(SECOND)
2320 // expected-error@second.h:* {{'Friend::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2321 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2324 } // namespace Friend
2326 namespace TemplateParameters {
2330 #elif defined(SECOND)
2334 using TemplateParameters::S1;
2335 // expected-error@second.h:* {{'TemplateParameters::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter 'B'}}
2336 // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}}
2340 template <class A = double>
2342 #elif defined(SECOND)
2343 template <class A = int>
2346 using TemplateParameters::S2;
2347 // expected-error@second.h:* {{'TemplateParameters::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}}
2348 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2352 template <class A = int>
2354 #elif defined(SECOND)
2358 using TemplateParameters::S3;
2359 // expected-error@second.h:* {{'TemplateParameters::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with no default argument}}
2360 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with default argument}}
2366 #elif defined(SECOND)
2367 template <int A = 2>
2370 using TemplateParameters::S4;
2371 // expected-error@second.h:* {{'TemplateParameters::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}}
2372 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with no default argument}}
2376 template <int> class S5_first {};
2377 template <template<int> class A = S5_first>
2379 #elif defined(SECOND)
2380 template <int> class S5_second {};
2381 template <template<int> class A = S5_second>
2384 using TemplateParameters::S5;
2385 // expected-error@second.h:* {{'TemplateParameters::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}}
2386 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2392 #elif defined(SECOND)
2396 using TemplateParameters::S6;
2397 // expected-error@second.h:* {{'TemplateParameters::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found unnamed template parameter}}
2398 // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}}
2403 #if defined(FIRST) || defined(SECOND)
2404 template <class> class DefaultArg;
2407 #if defined(FIRST) || defined(SECOND)
2408 template <int, class, template <class> class,
2409 int A, class B, template <int> class C,
2410 int D = 1, class E = int, template <class F> class = DefaultArg>
2415 using TemplateParameters::Valid1;
2418 #if defined(FIRST) || defined(SECOND)
2419 template <int, class, template <class> class,
2420 int A, class B, template <int> class C,
2421 int D = 1, class E = int, template <class F> class = DefaultArg>
2427 using TemplateParameters::Invalid1;
2428 // expected-error@second.h:* {{'TemplateParameters::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2429 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2432 } // namespace TemplateParameters
2434 namespace BaseClass {
2438 #elif defined(SECOND)
2442 // expected-error@second.h:* {{'BaseClass::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 base classes}}
2443 // expected-note@first.h:* {{but in 'FirstModule' found 1 base class}}
2448 #elif defined(SECOND)
2450 struct S2 : virtual B2 {};
2453 // expected-error@second.h:* {{'BaseClass::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 base class}}
2454 // expected-note@first.h:* {{but in 'FirstModule' found 0 base classes}}
2460 #elif defined(SECOND)
2462 struct S3 : virtual B3b {};
2465 // expected-error@second.h:* {{'BaseClass::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}}
2466 // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}}
2472 #elif defined(SECOND)
2477 // expected-error@second.h:* {{'BaseClass::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class with type 'BaseClass::B4b'}}
2478 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class with different type 'BaseClass::B4a'}}
2483 struct S5 : virtual B5a {};
2484 #elif defined(SECOND)
2489 // expected-error@second.h:* {{'BaseClass::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 virtual base classes}}
2490 // expected-note@first.h:* {{but in 'FirstModule' found 1 virtual base class}}
2496 #elif defined(SECOND)
2498 struct S6 : virtual B6a {};
2501 // expected-error@second.h:* {{'BaseClass::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}}
2502 // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}}
2507 struct S7 : protected B7a {};
2508 #elif defined(SECOND)
2513 // expected-error@second.h:* {{'BaseClass::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B7a' with no access specifier}}
2514 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B7a' with protected access specifier}}
2519 struct S8 : public B8a {};
2520 #elif defined(SECOND)
2522 struct S8 : private B8a {};
2525 // expected-error@second.h:* {{'BaseClass::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B8a' with private access specifier}}
2526 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B8a' with public access specifier}}
2531 struct S9 : private B9a {};
2532 #elif defined(SECOND)
2534 struct S9 : public B9a {};
2537 // expected-error@second.h:* {{'BaseClass::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B9a' with public access specifier}}
2538 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B9a' with private access specifier}}
2543 struct S10 : B10a {};
2544 #elif defined(SECOND)
2546 struct S10 : protected B10a {};
2549 // expected-error@second.h:* {{'BaseClass::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B10a' with protected access specifier}}
2550 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B10a' with no access specifier}}
2555 #if defined(FIRST) || defined(SECOND)
2563 #if defined(FIRST) || defined(SECOND)
2565 Base1, virtual Base2, protected Base3, public Base4, private Base5 {
2573 #if defined(FIRST) || defined(SECOND)
2575 Base1, virtual Base2, protected Base3, public Base4, private Base5 {
2582 // expected-error@second.h:* {{'BaseClass::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2583 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2586 } // namespace BaseClass
2588 namespace PointersAndReferences {
2589 #if defined(FIRST) || defined(SECOND)
2590 template<typename> struct Wrapper{};
2597 #elif defined(SECOND)
2603 // expected-error@first.h:* {{PointersAndReferences::S1::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S1' in module 'SecondModule'}}
2604 // expected-note@second.h:* {{declaration of 'x' does not match}}
2611 #elif defined(SECOND)
2613 Wrapper<float &&> x;
2617 // expected-error@first.h:* {{PointersAndReferences::S2::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S2' in module 'SecondModule'}}
2618 // expected-note@second.h:* {{declaration of 'x' does not match}}
2625 #elif defined(SECOND)
2631 // expected-error@first.h:* {{PointersAndReferences::S3::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S3' in module 'SecondModule'}}
2632 // expected-note@second.h:* {{declaration of 'x' does not match}}
2639 #elif defined(SECOND)
2645 // expected-error@first.h:* {{PointersAndReferences::S4::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S4' in module 'SecondModule'}}
2646 // expected-note@second.h:* {{declaration of 'x' does not match}}
2653 #elif defined(SECOND)
2655 Wrapper<const S5 *> x;
2659 // expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 'SecondModule' is not present in definition of 'PointersAndReferences::S5' in module 'FirstModule'}}
2660 // expected-note@first.h:* {{declaration of 'x' does not match}}
2667 #elif defined(SECOND)
2669 Wrapper<const int &> x;
2673 // expected-error@first.h:* {{PointersAndReferences::S6::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S6' in module 'SecondModule'}}
2674 // expected-note@second.h:* {{declaration of 'x' does not match}}
2678 Wrapper<int *> x1; \
2679 Wrapper<float *> x2; \
2680 Wrapper<const float *> x3; \
2681 Wrapper<int &> x4; \
2682 Wrapper<int &&> x5; \
2683 Wrapper<const int &> x6; \
2688 #if defined(FIRST) || defined(SECOND)
2696 #if defined(FIRST) || defined(SECOND)
2703 // expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2704 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2707 } // namespace PointersAndReferences
2709 namespace FunctionTemplate {
2712 template <int, int> void foo();
2714 #elif defined(SECOND)
2716 template <int> void foo();
2720 // expected-error@first.h:* {{'FunctionTemplate::S1::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S1' in module 'SecondModule'}}
2721 // expected-note@second.h:* {{declaration of 'foo' does not match}}
2726 template <char> void foo();
2728 #elif defined(SECOND)
2730 template <int> void foo();
2734 // expected-error@first.h:* {{'FunctionTemplate::S2::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S2' in module 'SecondModule'}}
2735 // expected-note@second.h:* {{declaration of 'foo' does not match}}
2740 template <int x> void foo();
2742 #elif defined(SECOND)
2744 template <int y> void foo();
2748 // expected-error@second.h:* {{'FunctionTemplate::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter named 'y'}}
2749 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}}
2754 template <int x> void foo();
2756 #elif defined(SECOND)
2758 template <int x> void bar();
2762 // expected-error@first.h:* {{'FunctionTemplate::S4::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S4' in module 'SecondModule'}}
2763 // expected-note@second.h:* {{definition has no member 'foo'}}
2768 template <int x> void foo();
2770 #elif defined(SECOND)
2773 template <int x> void foo();
2777 // expected-error@second.h:* {{'FunctionTemplate::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
2778 // expected-note@first.h:* {{but in 'FirstModule' found function template}}
2783 template <typename x = int> void foo();
2785 #elif defined(SECOND)
2787 template <typename x> void foo();
2791 // expected-error@second.h:* {{'FunctionTemplate::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no default argument}}
2792 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
2797 template <typename x = void> void foo();
2799 #elif defined(SECOND)
2801 template <typename x = int> void foo();
2805 // expected-error@second.h:* {{'FunctionTemplate::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 'int'}}
2806 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'void'}}
2813 template <template<int> class x = U8> void foo();
2815 #elif defined(SECOND)
2819 template <template<int> class x = T8> void foo();
2823 // expected-error@second.h:* {{'FunctionTemplate::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 'T8'}}
2824 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'U8'}}
2831 template <template<int> class x = U9> void foo();
2833 #elif defined(SECOND)
2835 template <template<int> class x> void foo();
2839 // expected-error@second.h:* {{'FunctionTemplate::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no default argument}}
2840 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
2845 template <template<int> class x> void foo();
2846 template <template<typename> class x> void foo();
2848 #elif defined(SECOND)
2850 template <template<typename> class x> void foo();
2851 template <template<int> class x> void foo();
2855 // expected-error@second.h:* {{'FunctionTemplate::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with one type}}
2856 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}}
2861 template <template<int> class x> void foo();
2863 #elif defined(SECOND)
2865 template <template<int> class> void foo();
2869 // expected-error@second.h:* {{'FunctionTemplate::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no name}}
2870 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}}
2875 template <class> void foo();
2876 template <class, class> void foo();
2878 #elif defined(SECOND)
2880 template <class, class> void foo();
2881 template <class> void foo();
2885 // expected-error@second.h:* {{'FunctionTemplate::S12' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 2 template parameters}}
2886 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1 template parameter}}
2891 template <class = int> void foo();
2893 #elif defined(SECOND)
2895 template <class = void> void foo();
2899 // expected-error@second.h:* {{'FunctionTemplate::S13' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 'void'}}
2900 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'int'}}
2905 template <class = void> void foo();
2907 #elif defined(SECOND)
2909 template <class> void foo();
2913 // expected-error@second.h:* {{'FunctionTemplate::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no default argument}}
2914 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
2919 template <class> void foo();
2921 #elif defined(SECOND)
2923 template <class = void> void foo();
2927 // expected-error@second.h:* {{'FunctionTemplate::S15' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument}}
2928 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}}
2933 template <short> void foo();
2935 #elif defined(SECOND)
2937 template <short = 1> void foo();
2941 // expected-error@second.h:* {{'FunctionTemplate::S16' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument}}
2942 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}}
2947 template <short = 2> void foo();
2949 #elif defined(SECOND)
2951 template <short = 1 + 1> void foo();
2955 // expected-error@second.h:* {{'FunctionTemplate::S17' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 1 + 1}}
2956 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 2}}
2961 template <short> void foo();
2962 template <int> void foo();
2964 #elif defined(SECOND)
2966 template <int> void foo();
2967 template <short> void foo();
2971 // expected-error@second.h:* {{'FunctionTemplate::S18' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with one type}}
2972 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}}
2977 template <short> void foo();
2978 template <short...> void foo();
2980 #elif defined(SECOND)
2982 template <short...> void foo();
2983 template <short> void foo();
2987 // expected-error@second.h:* {{'FunctionTemplate::S19' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a template parameter pack}}
2988 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}}
2993 template <class> void foo();
2994 template <class...> void foo();
2996 #elif defined(SECOND)
2998 template <class...> void foo();
2999 template <class> void foo();
3003 // expected-error@second.h:* {{'FunctionTemplate::S20' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a template parameter pack}}
3004 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}}
3009 template <template<class> class...> void foo();
3010 template <template<class> class> void foo();
3012 #elif defined(SECOND)
3014 template <template<class> class> void foo();
3015 template <template<class> class...> void foo();
3019 // expected-error@second.h:* {{'FunctionTemplate::S21' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter not being a template parameter pack}}
3020 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter being a template parameter pack}}
3025 template <template<class> class> void foo();
3026 template <class> void foo();
3027 template <int> void foo();
3029 #elif defined(SECOND)
3031 template <class> void foo();
3032 template <int> void foo();
3033 template <template<class> class> void foo();
3037 // expected-error@second.h:* {{'FunctionTemplate::S22' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a type template parameter}}
3038 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a template template parameter}}
3043 template <class> void foo();
3044 template <int> void foo();
3045 template <template<class> class> void foo();
3047 #elif defined(SECOND)
3049 template <int> void foo();
3050 template <template<class> class> void foo();
3051 template <class> void foo();
3055 // expected-error@second.h:* {{'FunctionTemplate::S23' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a non-type template parameter}}
3056 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a type template parameter}}
3061 template <int> void foo();
3062 template <template<class> class> void foo();
3063 template <class> void foo();
3065 #elif defined(SECOND)
3067 template <template<class> class> void foo();
3068 template <class> void foo();
3069 template <int> void foo();
3073 // expected-error@second.h:* {{'FunctionTemplate::S24' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a template template parameter}}
3074 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a non-type template parameter}}
3079 template <int> void foo();
3081 #elif defined(SECOND)
3084 template <int> void foo();
3088 // expected-error@second.h:* {{'FunctionTemplate::S25' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3089 // expected-note@first.h:* {{but in 'FirstModule' found function template}}
3097 template <int, int> \
3099 template <int x = 5> \
3101 template <int... x> \
3106 template <class x> \
3108 template <class, class> \
3110 template <class x = int> \
3112 template <class... x> \
3115 template <template <int> class> \
3117 template <template <int> class x> \
3119 template <template <int> class, template <int> class> \
3121 template <template <int> class x = U> \
3123 template <template <int> class... x> \
3126 #if defined(FIRST) || defined(SECOND)
3136 #if defined(FIRST) || defined(SECOND)
3143 // expected-error@second.h:* {{'FunctionTemplate::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3144 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3152 #elif defined(SECOND)
3156 // expected-error@first.h:* {{'Enums::x11' from module 'FirstModule' is not present in definition of 'Enums::E1' in module 'SecondModule'}}
3157 // expected-note@second.h:* {{definition has no member 'x11'}}
3162 #elif defined(SECOND)
3166 // expected-error@second.h:* {{'Enums::E2' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 1 element}}
3167 // expected-note@first.h:* {{but in 'FirstModule' found enum with 0 elements}}
3172 #elif defined(SECOND)
3176 // expected-error@first.h:* {{'Enums::x31' from module 'FirstModule' is not present in definition of 'Enums::E3' in module 'SecondModule'}}
3177 // expected-note@second.h:* {{definition has no member 'x31'}}
3182 #elif defined(SECOND)
3183 enum E4 { x41, x42 };
3186 // expected-error@second.h:* {{'Enums::E4' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 2 elements}}
3187 // expected-note@first.h:* {{but in 'FirstModule' found enum with 1 element}}
3191 enum E5 { x51, x52 };
3192 #elif defined(SECOND)
3196 // expected-error@first.h:* {{'Enums::x52' from module 'FirstModule' is not present in definition of 'Enums::E5' in module 'SecondModule'}}
3197 // expected-note@second.h:* {{definition has no member 'x52'}}
3201 enum E6 { x61, x62 };
3202 #elif defined(SECOND)
3203 enum E6 { x62, x61 };
3206 // expected-error@second.h:* {{'Enums::E6' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element has name 'x62'}}
3207 // expected-note@first.h:* {{but in 'FirstModule' found 1st element has name 'x61'}}
3211 enum E7 { x71 = 0 };
3212 #elif defined(SECOND)
3216 // expected-error@second.h:* {{'Enums::E7' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element 'x71' has an initilizer}}
3217 // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x71' does not have an initializer}}
3222 #elif defined(SECOND)
3223 enum E8 { x81 = 0 };
3226 // expected-error@second.h:* {{'Enums::E8' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element 'x81' does not have an initilizer}}
3227 // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x81' has an initializer}}
3231 enum E9 { x91 = 0, x92 = 1 };
3232 #elif defined(SECOND)
3233 enum E9 { x91 = 0, x92 = 2 - 1 };
3236 // expected-error@second.h:* {{'Enums::E9' has different definitions in different modules; definition in module 'SecondModule' first difference is 2nd element 'x92' has an initializer}}
3237 // expected-note@first.h:* {{but in 'FirstModule' found 2nd element 'x92' has different initializer}}
3241 enum class E10 : int {};
3242 #elif defined(SECOND)
3246 // expected-error@second.h:* {{'Enums::E10' has different definitions in different modules; definition in module 'SecondModule' first difference is enum without specified type}}
3247 // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type}}
3252 #elif defined(SECOND)
3256 // expected-error@second.h:* {{'Enums::E11' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type}}
3257 // expected-note@first.h:* {{but in 'FirstModule' found enum without specified type}}
3261 enum struct E12 : long {};
3262 #elif defined(SECOND)
3263 enum struct E12 : int {};
3266 // expected-error@second.h:* {{'Enums::E12' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type 'int'}}
3267 // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type 'long'}}
3272 #elif defined(SECOND)
3276 // expected-error@second.h:* {{'Enums::E13' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is not scoped}}
3277 // expected-note@first.h:* {{but in 'FirstModule' found enum that is scoped}}
3282 #elif defined(SECOND)
3286 // expected-error@second.h:* {{'Enums::E14' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is scoped}}
3287 // expected-note@first.h:* {{but in 'FirstModule' found enum that is not scoped}}
3292 #elif defined(SECOND)
3296 // expected-error@second.h:* {{'Enums::E15' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword struct}}
3297 // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword class}}
3302 #elif defined(SECOND)
3306 // expected-error@second.h:* {{'Enums::E16' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword class}}
3307 // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword struct}}
3311 enum Valid { v1 = (struct S*)0 == (struct S*)0 };
3312 #elif defined(SECOND)
3314 enum Valid { v1 = (struct S*)0 == (struct S*)0 };
3318 } // namespace Enums
3320 // Collection of interesting cases below.
3322 // Naive parsing of AST can lead to cycles in processing. Ensure
3323 // self-references don't trigger an endless cycles of AST node processing.
3324 namespace SelfReference {
3326 template <template <int> class T> class Wrapper {};
3328 template <int N> class S {
3329 S(Wrapper<::SelfReference::S> &Ref) {}
3340 template <typename> struct Foo;
3341 template <template <class> class T = NNS::Foo>
3342 struct NestedNamespaceSpecifier {};
3345 } // namespace SelfReference
3347 namespace FriendFunction {
3350 struct S { friend void F(int); };
3351 #elif defined(SECOND)
3353 struct S { friend void F(int); };
3365 #elif defined(SECOND)
3374 // expected-error@second.h:* {{'FriendFunction::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3375 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
3377 } // namespace FriendFunction
3379 namespace ImplicitDecl {
3382 void S_Constructors() {
3383 // Trigger creation of implicit contructors
3388 #elif defined(SECOND)
3398 void T_Constructors() {
3399 // Trigger creation of implicit contructors
3404 #elif defined(SECOND)
3410 // expected-error@first.h:* {{'ImplicitDecl::T' has different definitions in different modules; first difference is definition in module 'FirstModule' found private access specifier}}
3411 // expected-note@second.h:* {{but in 'SecondModule' found public access specifier}}
3414 } // namespace ImplicitDecl
3416 namespace TemplatedClass {
3420 #elif defined(SECOND)
3432 #elif defined(SECOND)
3439 // expected-error@second.h:* {{'TemplatedClass::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3440 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
3442 } // namespace TemplatedClass
3444 namespace TemplateClassWithField {
3450 #elif defined(SECOND)
3466 #elif defined(SECOND)
3475 // expected-error@second.h:* {{'TemplateClassWithField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3476 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
3478 } // namespace TemplateClassWithField
3480 namespace TemplateClassWithTemplateField {
3488 #elif defined(SECOND)
3510 #elif defined(SECOND)
3523 // expected-error@second.h:* {{'TemplateClassWithTemplateField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3524 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3526 } // namespace TemplateClassWithTemplateField
3528 namespace EnumWithForwardDeclaration {
3534 #elif defined(SECOND)
3535 enum E : int { A, B };
3548 #elif defined(SECOND)
3555 // expected-error@second.h:* {{'EnumWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3556 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3558 } // namespace EnumWithForwardDeclaration
3560 namespace StructWithForwardDeclaration {
3566 #elif defined(SECOND)
3580 #elif defined(SECOND)
3587 // expected-error@second.h:* {{'StructWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3588 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3590 } // namespace StructWithForwardDeclaration
3592 namespace StructWithForwardDeclarationNoDefinition {
3598 #elif defined(SECOND)
3613 #elif defined(SECOND)
3621 // expected-error@second.h:* {{'StructWithForwardDeclarationNoDefinition::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3622 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3624 } // namespace StructWithForwardDeclarationNoDefinition
3626 namespace LateParsedDefaultArgument {
3628 template <typename T>
3631 void foo(T x = 0) {}
3634 #elif defined(SECOND)
3640 } // namespace LateParsedDefaultArgument
3642 namespace LateParsedDefaultArgument {
3644 template <typename alpha> struct Bravo {
3645 void charlie(bool delta = false) {}
3647 typedef Bravo<char> echo;
3651 #elif defined(SECOND)
3654 } // LateParsedDefaultArgument
3656 namespace DifferentParameterNameInTemplate {
3657 #if defined(FIRST) || defined(SECOND)
3658 template <typename T>
3662 static void Run(const Type *name_one);
3665 template <typename T>
3666 void S<T>::Run(const T *name_two) {}
3668 template <typename T>
3670 ~Foo() { Handler::Run(nullptr); }
3673 class Handler : public S<T> {};
3675 void Get(typename Handler::Type *x = nullptr) {}
3676 void Add() { Handler::Run(nullptr); }
3685 void Go() { betas.Get(); }
3689 #elif defined(SECOND)
3693 void add_Beta() { betas.Add(); }
3700 } // DifferentParameterNameInTemplate
3702 namespace ParameterTest {
3705 template <typename G>
3709 static inline G *Foo(const G *a, int * = nullptr);
3712 template<typename G>
3713 G* S<G>::Foo(const G* aaaa, int*) {}
3714 #elif defined(SECOND)
3715 template <typename G>
3719 static inline G *Foo(const G *a, int * = nullptr);
3722 template<typename G>
3723 G* S<G>::Foo(const G* asdf, int*) {}
3729 namespace MultipleTypedefs {
3736 #elif defined(SECOND)
3746 struct T2 { int x; };
3752 #elif defined(SECOND)
3753 struct T2 { int x; };
3763 using A3 = const int;
3764 using B3 = volatile A3;
3768 #elif defined(SECOND)
3769 using A3 = volatile const int;
3784 #elif defined(SECOND)
3786 using B4 = ::MultipleTypedefs::A4;
3796 using B5 = MultipleTypedefs::A5;
3800 #elif defined(SECOND)
3802 using B5 = ::MultipleTypedefs::A5;
3809 } // MultipleTypedefs
3811 namespace DefaultArguments {
3813 template <typename T>
3819 #elif defined(SECOND)
3820 template <typename T>
3830 // expected-error@second.h:* {{'DefaultArguments::S::R' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'foo' with 1st parameter with a default argument}}
3831 // expected-note@first.h:* {{but in 'FirstModule' found method 'foo' with 1st parameter with a different default argument}}
3835 template <typename alpha> struct Bravo {
3836 void charlie(bool delta = false);
3838 typedef Bravo<char> echo;
3840 #elif defined(SECOND)
3841 template <typename alpha> struct Bravo {
3842 void charlie(bool delta = (false));
3844 typedef Bravo<char> echo;
3848 // expected-error@second.h:* {{'DefaultArguments::Bravo' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'charlie' with 1st parameter with a default argument}}
3849 // expected-note@first.h:* {{but in 'FirstModule' found method 'charlie' with 1st parameter with a different default argument}}
3851 } // namespace DefaultArguments
3853 namespace FunctionDecl {
3857 #elif defined(SECOND)
3868 #elif defined(SECOND)
3881 #elif defined(SECOND)
3889 #if defined(FIRST) || defined(SECOND)
3890 int F1(int x, float y = 2.7) { return 1; }
3896 int F2() { return 1; }
3897 #elif defined(SECOND)
3898 double F2() { return 1; }
3901 // expected-error@-1 {{call to 'F2' is ambiguous}}
3902 // expected-note@first.h:* {{candidate function}}
3903 // expected-note@second.h:* {{candidate function}}
3907 int F3(float) { return 1; }
3908 #elif defined(SECOND)
3909 int F3(double) { return 1; }
3912 // expected-error@-1 {{call to 'F3' is ambiguous}}
3913 // expected-note@first.h:* {{candidate function}}
3914 // expected-note@second.h:* {{candidate function}}
3918 int F4(int x) { return 1; }
3919 #elif defined(SECOND)
3920 int F4(int y) { return 1; }
3923 // expected-error@second.h:* {{'FunctionDecl::F4' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with name 'y'}}
3924 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with name 'x'}}
3928 int F5(int x) { return 1; }
3929 #elif defined(SECOND)
3930 int F5(int x = 1) { return 1; }
3933 // expected-error@second.h:* {{'FunctionDecl::F5' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter without a default argument}}
3934 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a default argument}}
3938 int F6(int x = 2) { return 1; }
3939 #elif defined(SECOND)
3940 int F6(int x = 1) { return 1; }
3943 // expected-error@second.h:* {{'FunctionDecl::F6' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with a default argument}}
3944 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a different default argument}}
3949 I F7() { return 0; }
3950 #elif defined(SECOND)
3951 int F7() { return 0; }
3954 // expected-error@second.h:* {{'FunctionDecl::F7' has different definitions in different modules; definition in module 'SecondModule' first difference is return type is 'int'}}
3955 // expected-note@first.h:* {{but in 'FirstModule' found different return type 'FunctionDecl::I' (aka 'int')}}
3959 int F8(int) { return 0; }
3960 #elif defined(SECOND)
3961 int F8(I) { return 0; }
3964 // expected-error@second.h:* {{'FunctionDecl::F8' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with type 'FunctionDecl::I' (aka 'int')}}
3965 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int'}}
3969 int F9(int[1]) { return 0; }
3970 #elif defined(SECOND)
3971 int F9(int[2]) { return 0; }
3973 int I9 = F9(nullptr);
3974 // expected-error@second.h:* {{'FunctionDecl::F9' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with type 'int *' decayed from 'int [2]'}}
3975 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int *' decayed from 'int [1]'}}
3979 int F10() { return 1; }
3980 #elif defined(SECOND)
3981 int F10() { return 2; }
3985 // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3986 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3990 template <int> void foo();
3992 #elif defined(SECOND)
3994 template <int> void foo();
3996 template <int> void S11::foo() {}
4005 #elif defined(SECOND)
4009 void S12::foo(int y) {}
4018 void S13::foo(int y) {}
4019 #elif defined(SECOND)
4023 void S13::foo(int y) {}
4027 } // namespace FunctionDecl
4029 namespace DeclTemplateArguments {
4031 int foo() { return 1; }
4032 int bar() { return foo(); }
4033 #elif defined(SECOND)
4034 template <class T = int>
4035 int foo() { return 2; }
4036 int bar() { return foo<>(); }
4039 // expected-error@second.h:* {{'DeclTemplateArguments::bar' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4040 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4044 // Keep macros contained to one file.