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++20 %t/Inputs/first.h
17 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++20 %t/Inputs/second.h
19 // Build module map file
20 // RUN: echo "module FirstModule {" >> %t/Inputs/module.modulemap
21 // RUN: echo " header \"first.h\"" >> %t/Inputs/module.modulemap
22 // RUN: echo "}" >> %t/Inputs/module.modulemap
23 // RUN: echo "module SecondModule {" >> %t/Inputs/module.modulemap
24 // RUN: echo " header \"second.h\"" >> %t/Inputs/module.modulemap
25 // RUN: echo "}" >> %t/Inputs/module.modulemap
28 // RUN: %clang_cc1 -triple x86_64-linux-gnu -x c++ -std=c++20 \
29 // RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
30 // RUN: -I%t/Inputs -verify %s
32 #if !defined(FIRST) && !defined(SECOND)
39 #define ACCESS public:
41 #define ACCESS private:
44 namespace AccessSpecifiers
{
54 // expected-error@second.h:* {{'AccessSpecifiers::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
55 // expected-note@first.h:* {{but in 'FirstModule' found end of class}}
68 // expected-error@second.h:* {{'AccessSpecifiers::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found protected access specifier}}
69 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
77 #if defined(FIRST) || defined(SECOND)
85 #if defined(FIRST) || defined(SECOND)
92 // expected-error@second.h:* {{'AccessSpecifiers::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
93 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
97 } // namespace AccessSpecifiers
99 namespace StaticAssert
{
102 static_assert(1 == 1, "First");
104 #elif defined(SECOND)
106 static_assert(1 == 1, "Second");
110 // expected-error@second.h:* {{'StaticAssert::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with message}}
111 // expected-note@first.h:* {{but in 'FirstModule' found static assert with different message}}
116 static_assert(2 == 2, "Message");
118 #elif defined(SECOND)
120 static_assert(2 == 2);
124 // 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}}
125 // expected-note@first.h:* {{but in 'FirstModule' found static assert with message}}
130 static_assert(3 == 3, "Message");
132 #elif defined(SECOND)
134 static_assert(3 != 4, "Message");
138 // expected-error@second.h:* {{'StaticAssert::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with condition}}
139 // expected-note@first.h:* {{but in 'FirstModule' found static assert with different condition}}
144 static_assert(4 == 4, "Message");
146 #elif defined(SECOND)
152 // expected-error@second.h:* {{'StaticAssert::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
153 // expected-note@first.h:* {{but in 'FirstModule' found static assert}}
157 static_assert(4 == 4, "Message"); \
158 static_assert(5 == 5);
160 #if defined(FIRST) || defined(SECOND)
168 #if defined(FIRST) || defined(SECOND)
175 // expected-error@second.h:* {{'StaticAssert::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
176 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
179 } // namespace StaticAssert
188 #elif defined(SECOND)
195 // expected-error@second.h:* {{'Field::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}}
196 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
204 #elif defined(SECOND)
211 // expected-error@second.h:* {{'Field::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}}
212 // expected-note@first.h:* {{but in 'FirstModule' found field 'x'}}
219 #elif defined(SECOND)
225 // expected-error@first.h:* {{'Field::S3::x' from module 'FirstModule' is not present in definition of 'Field::S3' in module 'SecondModule'}}
226 // expected-note@second.h:* {{declaration of 'x' does not match}}
238 #elif defined(SECOND)
249 // expected-error@second.h:* {{'Field::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'B' (aka 'int')}}
250 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'A' (aka 'int')}}
253 // 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'}}
254 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'A' (aka 'int')}}
261 #elif defined(SECOND)
267 // expected-error@second.h:* {{'Field::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found bitfield 'x'}}
268 // expected-note@first.h:* {{but in 'FirstModule' found non-bitfield 'x'}}
275 #elif defined(SECOND)
281 // 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}}
282 // expected-note@first.h:* {{but in 'FirstModule' found bitfield 'x' with different width expression}}
289 #elif defined(SECOND)
295 // 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}}
296 // expected-note@first.h:* {{but in 'FirstModule' found bitfield 'x' with different width expression}}
303 #elif defined(SECOND)
309 // expected-error@second.h:* {{'Field::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found non-mutable field 'x'}}
310 // expected-note@first.h:* {{but in 'FirstModule' found mutable field 'x'}}
317 #elif defined(SECOND)
323 // expected-error@second.h:* {{'Field::S9b' has different definitions in different modules; first difference is definition in module 'SecondModule' found non-mutable field 'x'}}
324 // expected-note@first.h:* {{but in 'FirstModule' found mutable field 'x'}}
331 #elif defined(SECOND)
337 // expected-error@second.h:* {{'Field::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with no initializer}}
338 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with an initializer}}
345 #elif defined(SECOND)
351 // 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}}
352 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}}
359 #elif defined(SECOND)
365 // expected-error@first.h:* {{'Field::S12::x' from module 'FirstModule' is not present in definition of 'Field::S12' in module 'SecondModule'}}
366 // expected-note@second.h:* {{declaration of 'x' does not match}}
373 #elif defined(SECOND)
379 // expected-error@first.h:* {{'Field::S13::x' from module 'FirstModule' is not present in definition of 'Field::S13' in module 'SecondModule'}}
380 // expected-note@second.h:* {{declaration of 'x' does not match}}
386 unsigned c : 1 + 2; \
393 #if defined(FIRST) || defined(SECOND)
397 #if defined(FIRST) || defined(SECOND)
405 #if defined(FIRST) || defined(SECOND)
412 // expected-error@second.h:* {{'Field::Invalid1' 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 public access specifier}}
423 #elif defined(SECOND)
430 // expected-error@second.h:* {{'Method::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
431 // expected-note@first.h:* {{but in 'FirstModule' found method}}
439 #elif defined(SECOND)
446 // expected-error@second.h:* {{'Method::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'B'}}
447 // expected-note@first.h:* {{but in 'FirstModule' found method 'A'}}
455 #elif defined(SECOND)
462 // 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}}
463 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is static}}
471 #elif defined(SECOND)
478 // 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}}
479 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is virtual}}
484 virtual void A() = 0;
487 #elif defined(SECOND)
490 virtual void B() = 0;
494 // expected-error@second.h:* {{'Method::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is virtual}}
495 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is pure virtual}}
502 #elif defined(SECOND)
508 // 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}}
509 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is inline}}
517 #elif defined(SECOND)
524 // 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}}
525 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is volatile}}
533 #elif defined(SECOND)
540 // 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}}
541 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is const}}
547 void A(int x
, int y
) {}
549 #elif defined(SECOND)
551 void A(int x
, int y
) {}
556 // 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}}
557 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' that has 1 parameter}}
565 #elif defined(SECOND)
572 // 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'}}
573 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int'}}
580 #elif defined(SECOND)
586 // 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'}}
587 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter named 'x'}}
594 #elif defined(SECOND)
600 // 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}}
601 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a default argument}}
606 void A(int x
= 1 + 0);
608 #elif defined(SECOND)
614 // 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}}
615 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a different default argument}}
622 #elif defined(SECOND)
628 // 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]'}}
629 // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int[2]'}}
634 int A() { return 0; }
636 #elif defined(SECOND)
638 long A() { return 0; }
642 // expected-error@first.h:* {{'Method::S15::A' from module 'FirstModule' is not present in definition of 'Method::S15' in module 'SecondModule'}}
643 // expected-note@second.h:* {{declaration of 'A' does not match}}
650 virtual void D() = 0; \
655 void I(int x = 5 + 5); \
660 #if defined(FIRST) || defined(SECOND)
668 #if defined(FIRST) || defined(SECOND)
675 // expected-error@second.h:* {{'Method::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
676 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
679 } // namespace Method
681 namespace MethodBody
{
684 int A() { return 0; }
686 #elif defined(SECOND)
688 int A() { return 0; }
696 int BothBodies() { return 0; }
698 #elif defined(SECOND)
700 int BothBodies() { return 1; }
704 // expected-error@first.h:* {{'MethodBody::S2' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'BothBodies' with body}}
705 // expected-note@second.h:* {{but in 'SecondModule' found method 'BothBodies' with different body}}
710 int FirstBody() { return 0; }
712 #elif defined(SECOND)
718 // expected-error@first.h:* {{'MethodBody::S3' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstBody' with body}}
719 // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstBody' with no body}}
726 #elif defined(SECOND)
728 int SecondBody() { return 0; }
732 // 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}}
733 // expected-note@second.h:* {{but in 'SecondModule' found method 'SecondBody' with body}}
738 int FirstBodySecondOutOfLine() { return 0; }
740 #elif defined(SECOND)
742 int FirstBodySecondOutOfLine();
744 int S5::FirstBodySecondOutOfLine() { return 0; }
747 // 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}}
748 // expected-note@first.h:* {{but in 'FirstModule' found method 'FirstBodySecondOutOfLine' with body}}
753 int FirstOutOfLineSecondBody();
755 int S6::FirstOutOfLineSecondBody() { return 0; }
756 #elif defined(SECOND)
758 int FirstOutOfLineSecondBody() { return 0; }
762 // 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}}
763 // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstOutOfLineSecondBody' with body}}
770 int S7::BothOutOfLine() { return 1; }
771 #elif defined(SECOND)
775 int S7::BothOutOfLine() { return 0; }
778 // expected-error@second.h:* {{'MethodBody::S7::BothOutOfLine' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
779 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
784 int FirstBodySecondOutOfLine() { return 0; }
786 #elif defined(SECOND)
788 int FirstBodySecondOutOfLine();
790 int S8::FirstBodySecondOutOfLine() { return 1; }
793 // 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}}
794 // expected-note@first.h:* {{but in 'FirstModule' found method 'FirstBodySecondOutOfLine' with body}}
799 int FirstOutOfLineSecondBody();
801 int S9::FirstOutOfLineSecondBody() { return 1; }
802 #elif defined(SECOND)
804 int FirstOutOfLineSecondBody() { return 0; }
808 // 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}}
809 // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstOutOfLineSecondBody' with body}}
817 #elif defined(SECOND)
824 // expected-error@first.h:* {{'MethodBody::S10' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is deleted}}
825 // expected-note@second.h:* {{but in 'SecondModule' found constructor is not deleted}}
832 #elif defined(SECOND)
838 // expected-error@first.h:* {{'MethodBody::S11' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is defaulted}}
839 // expected-note@second.h:* {{but in 'SecondModule' found constructor is not defaulted}}
842 #define DECLS(CLASSNAME) \
843 CLASSNAME() = default; \
844 ~CLASSNAME() = delete; \
846 void B() { return; }; \
850 #define OUTOFLINEDEFS(CLASSNAME) \
851 void CLASSNAME::C() {} \
852 void CLASSNAME::D() { return; }
854 #if defined(FIRST) || defined(SECOND)
858 OUTOFLINEDEFS(Valid1
)
863 #if defined(FIRST) || defined(SECOND)
868 OUTOFLINEDEFS(Invalid1
)
871 // expected-error@first.h:* {{'MethodBody::Invalid1' has different definitions in different modules; first difference is definition in module 'FirstModule' found public access specifier}}
872 // expected-note@second.h:* {{but in 'SecondModule' found private access specifier}}
875 } // namespace MethodBody
877 namespace Constructor
{
883 #elif defined(SECOND)
890 // expected-error@second.h:* {{'Constructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'foo'}}
891 // expected-note@first.h:* {{but in 'FirstModule' found constructor}}
899 #elif defined(SECOND)
906 // 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}}
907 // expected-note@first.h:* {{but in 'FirstModule' found constructor that has 1 parameter}}
910 #define DECLS(CLASS) \
915 #if defined(FIRST) || defined(SECOND)
923 #if defined(FIRST) || defined(SECOND)
930 // expected-error@second.h:* {{'Constructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
931 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
934 } // namespace Constructor
936 namespace Destructor
{
942 #elif defined(SECOND)
949 // expected-error@second.h:* {{'Destructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor}}
950 // expected-note@first.h:* {{but in 'FirstModule' found destructor}}
958 #elif defined(SECOND)
961 virtual void foo() {}
965 // expected-error@second.h:* {{'Destructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found destructor is not virtual}}
966 // expected-note@first.h:* {{but in 'FirstModule' found destructor is virtual}}
969 #if defined(FIRST) || defined(SECOND)
977 #if defined(FIRST) || defined(SECOND)
984 // expected-error@second.h:* {{'Destructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
985 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
988 #if defined(FIRST) || defined(SECOND)
996 #if defined(FIRST) || defined(SECOND)
1003 // expected-error@second.h:* {{'Destructor::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1004 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1006 } // namespace Destructor
1013 #elif defined(SECOND)
1019 // expected-error@first.h:* {{'TypeDef::S1::a' from module 'FirstModule' is not present in definition of 'TypeDef::S1' in module 'SecondModule'}}
1020 // expected-note@second.h:* {{declaration of 'a' does not match}}
1027 #elif defined(SECOND)
1033 // expected-error@first.h:* {{'TypeDef::S2::a' from module 'FirstModule' is not present in definition of 'TypeDef::S2' in module 'SecondModule'}}
1034 // expected-note@second.h:* {{definition has no member 'a'}}
1042 #elif defined(SECOND)
1049 // FIXME: We should reject the merge of `S3` due to the inconsistent definition of `T`.
1057 #elif defined(SECOND)
1064 // expected-error@second.h:* {{'TypeDef::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found typedef name 'b'}}
1065 // expected-note@first.h:* {{but in 'FirstModule' found typedef name 'a'}}
1074 #elif defined(SECOND)
1082 // expected-error@second.h:* {{'TypeDef::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}}
1083 // expected-note@first.h:* {{but in 'FirstModule' found typedef}}
1092 #elif defined(SECOND)
1099 // 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'}}
1100 // expected-note@first.h:* {{but in 'FirstModule' found typedef 'b' with different underlying type 'F' (aka 'float')}}
1108 #if defined(FIRST) || defined(SECOND)
1112 #if defined(FIRST) || defined(SECOND)
1120 #if defined(FIRST) || defined(SECOND)
1127 // expected-error@second.h:* {{'TypeDef::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1128 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1131 } // namespace TypeDef
1138 #elif defined(SECOND)
1144 // expected-error@first.h:* {{'Using::S1::a' from module 'FirstModule' is not present in definition of 'Using::S1' in module 'SecondModule'}}
1145 // expected-note@second.h:* {{declaration of 'a' does not match}}
1152 #elif defined(SECOND)
1158 // expected-error@first.h:* {{'Using::S2::a' from module 'FirstModule' is not present in definition of 'Using::S2' in module 'SecondModule'}}
1159 // expected-note@second.h:* {{definition has no member 'a'}}
1167 #elif defined(SECOND)
1174 // FIXME: We should reject the merge of `S3` due to the inconsistent definition of `T`.
1182 #elif defined(SECOND)
1189 // expected-error@second.h:* {{'Using::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias name 'b'}}
1190 // expected-note@first.h:* {{but in 'FirstModule' found type alias name 'a'}}
1199 #elif defined(SECOND)
1207 // expected-error@second.h:* {{'Using::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}}
1208 // expected-note@first.h:* {{but in 'FirstModule' found type alias}}
1217 #elif defined(SECOND)
1224 // 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'}}
1225 // expected-note@first.h:* {{but in 'FirstModule' found type alias 'b' with different underlying type 'F' (aka 'float')}}
1228 #if defined(FIRST) || defined(SECOND)
1237 #if defined(FIRST) || defined(SECOND)
1245 #if defined(FIRST) || defined(SECOND)
1252 // expected-error@second.h:* {{'Using::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1253 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1256 } // namespace Using
1258 namespace RecordType
{
1264 #elif defined(SECOND)
1271 // expected-error@first.h:* {{'RecordType::S1::x' from module 'FirstModule' is not present in definition of 'RecordType::S1' in module 'SecondModule'}}
1272 // expected-note@second.h:* {{declaration of 'x' does not match}}
1278 #if defined(FIRST) || defined(SECOND)
1282 #if defined(FIRST) || defined(SECOND)
1290 #if defined(FIRST) || defined(SECOND)
1297 // expected-error@second.h:* {{'RecordType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1298 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1301 } // namespace RecordType
1303 namespace DependentType
{
1307 typename
T::typeA x
;
1309 #elif defined(SECOND)
1312 typename
T::typeB x
;
1317 // expected-error@first.h:* {{'DependentType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T>' in module 'SecondModule'}}
1318 // expected-note@second.h:* {{declaration of 'x' does not match}}
1322 typename T::typeA x;
1324 #if defined(FIRST) || defined(SECOND)
1331 using V1
= Valid1
<T
>;
1334 #if defined(FIRST) || defined(SECOND)
1342 using I1
= Invalid1
<T
>;
1343 // expected-error@second.h:* {{'DependentType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1344 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1347 } // namespace DependentType
1349 namespace ElaboratedType
{
1351 namespace N1
{ using type
= double; }
1355 #elif defined(SECOND)
1356 namespace N1
{ using type
= int; }
1367 #if defined(FIRST) || defined(SECOND)
1368 namespace NS
{ using type
= float; }
1371 #if defined(FIRST) || defined(SECOND)
1379 #if defined(FIRST) || defined(SECOND)
1386 // expected-error@second.h:* {{'ElaboratedType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1387 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1390 } // namespace ElaboratedType
1398 #elif defined(SECOND)
1405 // expected-error@first.h:* {{'Enum::S1::x' from module 'FirstModule' is not present in definition of 'Enum::S1' in module 'SecondModule'}}
1406 // expected-note@second.h:* {{declaration of 'x' does not match}}
1412 #if defined(FIRST) || defined(SECOND)
1416 #if defined(FIRST) || defined(SECOND)
1424 #if defined(FIRST) || defined(SECOND)
1431 // expected-error@second.h:* {{'Enum::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1432 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1437 namespace NestedNamespaceSpecifier
{
1446 # elif defined(SECOND)
1454 LevelB1::LevelC1::Type x
;
1458 // 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')}}
1459 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA1::Type' (aka 'int')}}
1463 namespace LevelA2
{ using Type
= int; }
1467 # elif defined(SECOND)
1473 // 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'}}
1474 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA2::Type' (aka 'int')}}
1477 namespace LevelA3
{ using Type
= int; }
1478 namespace LevelB3
{ using Type
= int; }
1483 # elif defined(SECOND)
1489 // 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')}}
1490 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA3::Type' (aka 'int')}}
1494 struct TA4
{ using Type
= int; };
1498 # elif defined(SECOND)
1499 struct TB4
{ using Type
= int; };
1505 // 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')}}
1506 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'TA4::Type' (aka 'int')}}
1510 struct T5
{ using Type
= int; };
1514 # elif defined(SECOND)
1515 namespace T5
{ using Type
= int; };
1521 // 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')}}
1522 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'T5::Type' (aka 'int')}}
1526 namespace N6
{using I
= int;}
1528 NestedNamespaceSpecifier::N6::I x
;
1530 # elif defined(SECOND)
1533 ::NestedNamespaceSpecifier::I x
;
1537 // 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')}}
1538 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'NestedNamespaceSpecifier::N6::I' (aka 'int')}}
1542 template <class T
, class U
>
1544 typename
T::type
*x
= {};
1545 int z
= x
->T::foo();
1547 #elif defined(SECOND)
1548 template <class T
, class U
>
1550 typename
T::type
*x
= {};
1551 int z
= x
->U::foo();
1554 template <class T
, class U
>
1555 using U7
= S7
<T
, U
>;
1556 // 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}}
1557 // expected-note@first.h:* {{but in 'FirstModule' found field 'z' with a different initializer}}
1563 int x
= T::template X
<int>::value
;
1565 #elif defined(SECOND)
1568 int x
= T::template Y
<int>::value
;
1573 // 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}}
1574 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}}
1578 namespace N9
{ using I
= int; }
1583 #elif defined(SECOND)
1584 namespace N9
{ using I
= int; }
1591 // 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')}}
1592 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'O9::I' (aka 'int')}}
1597 inline namespace A
{ struct X
{}; }
1601 #elif defined(SECOND)
1602 inline namespace B
{ struct X
{}; }
1608 // expected-error@second.h:* {{'NestedNamespaceSpecifier::N10::S10::x' from module 'SecondModule' is not present in definition of 'NestedNamespaceSpecifier::N10::S10' in module 'FirstModule'}}
1609 // expected-note@first.h:* {{declaration of 'x' does not match}}
1619 #if defined(FIRST) || defined(SECOND)
1623 using Type
= double;
1627 namespace NS3
= NS1
;
1630 #if defined(FIRST) || defined(SECOND)
1638 #if defined(FIRST) || defined(SECOND)
1645 // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1646 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1651 typename T::type *x = {}; \
1652 int y = x->T::foo(); \
1653 int z = U::template X<int>::value;
1655 #if defined(FIRST) || defined(SECOND)
1656 template <class T
, class U
>
1661 template <class T
, class U
>
1662 using V2
= Valid2
<T
, U
>;
1665 #if defined(FIRST) || defined(SECOND)
1666 template <class T
, class U
>
1672 template <class T
, class U
>
1673 using I2
= Invalid2
<T
, U
>;
1674 // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1675 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1678 } // namespace NestedNamespaceSpecifier
1680 namespace TemplateSpecializationType
{
1682 template <class T1
> struct U1
{};
1686 #elif defined(SECOND)
1687 template <class T1
, class T2
> struct U1
{};
1693 // expected-error@first.h:* {{'TemplateSpecializationType::S1::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S1' in module 'SecondModule'}}
1694 // expected-note@second.h:* {{declaration of 'u' does not match}}
1698 template <class T1
> struct U2
{};
1702 #elif defined(SECOND)
1703 template <class T1
> struct V1
{};
1709 // expected-error@first.h:* {{'TemplateSpecializationType::S2::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S2' in module 'SecondModule'}}
1710 // expected-note@second.h:* {{declaration of 'u' does not match}}
1714 OneTemplateArg<int> x; \
1715 OneTemplateArg<double> y; \
1716 OneTemplateArg<char *> z; \
1717 TwoTemplateArgs<int, int> a; \
1718 TwoTemplateArgs<double, float> b; \
1719 TwoTemplateArgs<short *, char> c;
1721 #if defined(FIRST) || defined(SECOND)
1722 template <class T
> struct OneTemplateArg
{};
1723 template <class T
, class U
> struct TwoTemplateArgs
{};
1726 #if defined(FIRST) || defined(SECOND)
1734 #if defined(FIRST) || defined(SECOND)
1741 // expected-error@second.h:* {{'TemplateSpecializationType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
1742 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
1745 } // namespace TemplateSpecializationType
1747 namespace TemplateArgument
{
1749 template <class> struct U1
{};
1753 #elif defined(SECOND)
1754 template <int> struct U1
{};
1760 // expected-error@first.h:* {{'TemplateArgument::S1::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 'SecondModule'}}
1761 // expected-note@second.h:* {{declaration of 'x' does not match}}
1765 template <int> struct U2
{};
1769 #elif defined(SECOND)
1770 template <int> struct U2
{};
1776 // 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)>'}}
1777 // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U2<2>'}}
1781 template <int> struct U3
{};
1785 #elif defined(SECOND)
1786 template <int> struct U3
{};
1788 using T
= U3
<1 + 1>;
1792 // 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>'}}
1793 // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U3<2>'}}
1797 template<class> struct T4a
{};
1798 template <template <class> class T
> struct U4
{};
1802 #elif defined(SECOND)
1803 template<class> struct T4b
{};
1804 template <template <class> class T
> struct U4
{};
1810 // expected-error@first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}}
1811 // expected-note@second.h:* {{declaration of 'x' does not match}}
1815 template <class T
> struct U5
{};
1819 #elif defined(SECOND)
1820 template <class T
> struct U5
{};
1826 // expected-error@first.h:* {{'TemplateArgument::S5::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S5' in module 'SecondModule'}}
1827 // expected-note@second.h:* {{declaration of 'x' does not match}}
1831 template <class T
> struct U6
{};
1836 #elif defined(SECOND)
1837 template <class T
> struct U6
{};
1844 // expected-error@second.h:* {{'TemplateArgument::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}}
1845 // expected-note@first.h:* {{but in 'FirstModule' found field 'x'}}
1850 template<int> void run() {}
1851 template<> void run
<1>() {}
1853 #elif defined(SECOND)
1855 template<int> void run() {}
1860 // 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}}
1861 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with template arguments}}
1867 template<int&> void run() {}
1868 template<int&, int&> void run() {}
1869 template<> void run
<a
>() {}
1871 #elif defined(SECOND)
1874 template<int&> void run() {}
1875 template<int&, int&> void run() {}
1876 template<> void run
<a
, b
>() {}
1880 // 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}}
1881 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 1 template argument}}
1887 template<int&> void run() {}
1888 template<> void run
<a
>() {}
1890 #elif defined(SECOND)
1893 template<int&> void run() {}
1894 template<> void run
<b
>() {}
1898 // 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}}
1899 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 'a' for 1st template argument}}
1905 template<int, int&...> void run() {}
1906 template<> void run
<1, a
>() {}
1908 #elif defined(SECOND)
1911 template<int, int&...> void run() {}
1912 template<> void run
<1, b
>() {}
1916 // 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}}
1917 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 'a' for 2nd template argument}}
1923 template<int, int&...> void run() {}
1924 template<> void run
<1, a
>() {}
1926 #elif defined(SECOND)
1929 template<int, int&...> void run() {}
1930 template<> void run
<1, a
, a
>() {}
1934 // 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}}
1935 // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 2 template arguments}}
1940 template <int> void f(){};
1941 template <> void f
<1>(){};
1943 #elif defined(SECOND)
1945 template <int> void f(){};
1946 template <> void f
<2>(){};
1950 // expected-error@second.h:* {{'TemplateArgument::S12' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with 2 for 1st template argument}}
1951 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 1 for 1st template argument}}
1956 template <int> void f(){};
1957 template <> void f
<10>(){};
1959 #elif defined(SECOND)
1961 template <int> void f(){};
1962 template <> void f
<10>(){};
1970 template <bool, bool> void f(){};
1971 template <> void f
<true, false>(){};
1973 #elif defined(SECOND)
1975 template <bool, bool> void f(){};
1976 template <> void f
<false, true>(){};
1980 // expected-error@second.h:* {{'TemplateArgument::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with 0 for 1st template argument}}
1981 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 1 for 1st template argument}}
1986 template <bool, bool> void f(){};
1987 template <> void f
<true, true>(){};
1989 #elif defined(SECOND)
1991 template <bool, bool> void f(){};
1992 template <> void f
<true, true>(){};
2000 template <int *> void f(){};
2001 template <> void f
<nullptr>(){};
2003 #elif defined(SECOND)
2005 template <int *> void f(){};
2006 template <> void f
<nullptr>(){};
2015 template <int *> void f(){};
2016 template <> void f
<&x
>(){};
2018 #elif defined(SECOND)
2021 template <int *> void f(){};
2022 template <> void f
<nullptr>(){};
2026 // expected-error@second.h:* {{'TemplateArgument::S17' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with nullptr for 1st template argument}}
2027 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 'x' for 1st template argument}}
2033 template <int *> void f(){};
2034 template <> void f
<&x
>(){};
2036 #elif defined(SECOND)
2039 template <int *> void f(){};
2040 template <> void f
<&x
>(){};
2048 static constexpr _BitInt(128) x
= static_cast<_BitInt(128)>((unsigned long long)-1);
2049 template <_BitInt(128)> void f(){};
2050 template <> void f
<x
+ x
>(){};
2052 #elif defined(SECOND)
2054 static constexpr _BitInt(128) x
= static_cast<_BitInt(128)>((unsigned long long)-1);
2055 template <_BitInt(128)> void f(){};
2056 template <> void f
<x
+ x
>(){};
2064 static constexpr _BitInt(128) x
= static_cast<_BitInt(128)>((unsigned long long)-1);
2065 template <_BitInt(128)> void f(){};
2066 template <> void f
<x
+ x
>(){};
2068 #elif defined(SECOND)
2070 static constexpr _BitInt(128) x
= static_cast<_BitInt(128)>((unsigned long long)-1);
2071 template <_BitInt(128)> void f(){};
2072 template <> void f
<x
>(){};
2076 // expected-error@second.h:* {{'TemplateArgument::S20' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with 18446744073709551615 for 1st template argument}}
2077 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 36893488147419103230 for 1st template argument}}
2082 static constexpr _BitInt(128) x
= static_cast<_BitInt(128)>((unsigned long long)-1);
2083 template <_BitInt(128)> void f(){};
2084 template <> void f
<x
+ 0>(){};
2086 #elif defined(SECOND)
2088 static constexpr _BitInt(128) x
= static_cast<_BitInt(128)>((unsigned long long)-1);
2089 template <_BitInt(128)> void f(){};
2090 template <> void f
<(unsigned long long)-1>(){};
2098 template <double> void f(){};
2099 template <> void f
<1.5>(){};
2101 #elif defined(SECOND)
2103 template <double> void f(){};
2104 template <> void f
<1.7>(){};
2108 // expected-error@second.h:* {{'TemplateArgument::S22' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with 1.700000e+00 for 1st template argument}}
2109 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with 1.500000e+00 for 1st template argument}}
2114 template <double> void f(){};
2115 template <> void f
<2.7>(){};
2117 #elif defined(SECOND)
2119 template <double> void f(){};
2120 template <> void f
<2.7>(){};
2126 #if defined(FIRST) || defined(SECOND)
2131 extern Composite composite
;
2136 template <int&> void f(){};
2137 template <> void f
<composite
.n1
[1]>(){};
2139 #elif defined(SECOND)
2141 template <int&> void f(){};
2142 template <> void f
<composite
.n1
[2]>(){};
2146 // expected-error@second.h:* {{'TemplateArgument::S24' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with composite.n1[2] for 1st template argument}}
2147 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with composite.n1[1] for 1st template argument}}
2150 #if defined(FIRST) || defined(SECOND)
2152 template <int&> void f();
2153 template <> void f
<composite
.n1
[2]>();
2161 template <int*> void f(){};
2162 template <> void f
<&composite
.n1
[4]>(){}; // Past-the-end pointer.
2164 #elif defined(SECOND)
2166 template <int*> void f(){};
2167 template <> void f
<&composite
.n2
[0]>(){};
2171 // expected-error@second.h:* {{'TemplateArgument::S26' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with &composite.n2[0] for 1st template argument}}
2172 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with &composite.n1[4] for 1st template argument}}
2175 #if defined(FIRST) || defined(SECOND)
2185 template <int&> void f(){};
2186 template <> void f
<u
.i1
>(){};
2188 #elif defined(SECOND)
2190 template <int&> void f(){};
2191 template <> void f
<u
.i2
>(){};
2195 // expected-error@second.h:* {{'TemplateArgument::S27' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with u.i2 for 1st template argument}}
2196 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with u.i1 for 1st template argument}}
2199 #if defined(FIRST) || defined(SECOND)
2201 template <int&> void f(){};
2202 template <> void f
<u
.i1
>(){};
2208 #if defined(FIRST) || defined(SECOND)
2219 template <int D::*> void f(){};
2220 template <> void f
<(int D::*)(int B::*)&A::a
>(){};
2222 #elif defined(SECOND)
2224 template <int D::*> void f(){};
2225 template <> void f
<(int D::*)(int C::*)&A::a
>(){};
2229 // expected-error@second.h:* {{'TemplateArgument::S29' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with &A::a for 1st template argument}}
2230 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with &A::a for 1st template argument}}
2233 #if defined(FIRST) || defined(SECOND)
2235 template <int D::*> void f(){};
2236 template <> void f
<(int D::*)(int B::*)&A::a
>(){};
2244 template <auto*> void f(){};
2245 template <> void f
<&composite
.n1
[2]>(){};
2247 #elif defined(SECOND)
2249 template <auto*> void f(){};
2250 template <> void f
<(void*)&composite
.n1
[2]>(){};
2254 // expected-error@second.h:* {{'TemplateArgument::S31' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with &composite.n1[2] for 1st template argument}}
2255 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with &composite.n1[2] for 1st template argument}}
2260 template <int*> void f(){};
2261 template <> void f
<__builtin_constant_p(0) ? (int*)1 : (int*)1>(){};
2263 #elif defined(SECOND)
2265 template <int*> void f(){};
2266 template <> void f
<__builtin_constant_p(0) ? (int*)2 : (int*)2>(){};
2270 // expected-error@second.h:* {{'TemplateArgument::S32' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'f' with (int *)2 for 1st template argument}}
2271 // expected-note@first.h:* {{but in 'FirstModule' found method 'f' with (int *)1 for 1st template argument}}
2274 #if defined(FIRST) || defined(SECOND)
2276 template <int*> void f(){};
2277 template <> void f
<__builtin_constant_p(0) ? (int*)1 : (int*)1>(){};
2286 using c = OneClass<float>; \
2287 using d = OneInt<2>; \
2288 using e = OneInt<2 + 2>; \
2289 OneTemplateClass<OneClass> f; \
2290 OneTemplateInt<OneInt> g; \
2291 static int i1, i2; \
2293 void Function() {} \
2294 template <int &, int &> \
2295 void Function() {} \
2297 void Function<i1>() {} \
2299 void Function<i2>() {} \
2301 void Function<i1, i2>() {} \
2303 void Function<i2, i1>() {}
2305 #if defined(FIRST) || defined(SECOND)
2306 template <class> struct OneClass
{};
2307 template <int> struct OneInt
{};
2308 template <template <class> class> struct OneTemplateClass
{};
2309 template <template <int> class> struct OneTemplateInt
{};
2312 #if defined(FIRST) || defined(SECOND)
2320 #if defined(FIRST) || defined(SECOND)
2327 // expected-error@second.h:* {{'TemplateArgument::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2328 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2331 } // namespace TemplateArgument
2333 namespace TemplateTypeParmType
{
2335 template <class T1
, class T2
>
2339 #elif defined(SECOND)
2340 template <class T1
, class T2
>
2345 using TemplateTypeParmType::S1
;
2346 // expected-error@first.h:* {{'TemplateTypeParmType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T1, T2>' in module 'SecondModule'}}
2347 // expected-note@second.h:* {{declaration of 'x' does not match}}
2351 template <int ...Ts
>
2353 template <int T
, int U
>
2355 typedef U2
<U
, T
> type
;
2358 #elif defined(SECOND)
2359 template <int ...Ts
>
2361 template <int T
, int U
>
2363 typedef U2
<T
, U
> type
;
2367 using TemplateTypeParmType::S2
;
2368 // expected-error@first.h:* {{'TemplateTypeParmType::S2::x' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}}
2369 // expected-note@second.h:* {{declaration of 'x' does not match}}
2370 // expected-error@first.h:* {{'TemplateTypeParmType::S2::type' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}}
2371 // expected-note@second.h:* {{declaration of 'type' does not match}}
2377 ParameterPack<T> a; \
2378 ParameterPack<T, U> b; \
2379 ParameterPack<U> c; \
2380 ParameterPack<U, T> d;
2382 #if defined(FIRST) || defined(SECOND)
2383 template <class ...Ts
> struct ParameterPack
{};
2386 #if defined(FIRST) || defined(SECOND)
2387 template <class T
, class U
>
2392 using TemplateTypeParmType::Valid1
;
2395 #if defined(FIRST) || defined(SECOND)
2396 template <class T
, class U
>
2402 using TemplateTypeParmType::Invalid1
;
2403 // expected-error@second.h:* {{'TemplateTypeParmType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2404 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2407 } // namespace TemplateTypeParmType
2415 #elif defined(SECOND)
2422 // 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'}}
2423 // expected-note@first.h:* {{but in 'FirstModule' found data member with name 'x'}}
2430 #elif defined(SECOND)
2437 // 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 'I' (aka 'int')}}
2438 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with different type 'int'}}
2443 static const int x
= 1;
2445 #elif defined(SECOND)
2451 // 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}}
2452 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' without an initializer}}
2457 static const int x
= 1;
2459 #elif defined(SECOND)
2461 static const int x
= 2;
2465 // 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}}
2466 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with a different initializer}}
2471 static const int x
= 1;
2473 #elif defined(SECOND)
2475 static constexpr int x
= 1;
2479 // 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}}
2480 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' is constexpr}}
2485 static const int x
= 1;
2487 #elif defined(SECOND)
2489 static const int y
= 1;
2493 // expected-error@first.h:* {{'VarDecl::S6::x' from module 'FirstModule' is not present in definition of 'VarDecl::S6' in module 'SecondModule'}}
2494 // expected-note@second.h:* {{definition has no member 'x'}}
2499 static const int x
= 1;
2501 #elif defined(SECOND)
2503 static const unsigned x
= 1;
2507 // expected-error@first.h:* {{'VarDecl::S7::x' from module 'FirstModule' is not present in definition of 'VarDecl::S7' in module 'SecondModule'}}
2508 // expected-note@second.h:* {{declaration of 'x' does not match}}
2514 static const int x
= 1;
2516 #elif defined(SECOND)
2518 static const int x
= 1;
2523 // expected-error@second.h:* {{'VarDecl::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member}}
2524 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2529 static const int x
= 1;
2531 #elif defined(SECOND)
2537 // expected-error@first.h:* {{'VarDecl::S9::x' from module 'FirstModule' is not present in definition of 'VarDecl::S9' in module 'SecondModule'}}
2538 // expected-note@second.h:* {{declaration of 'x' does not match}}
2544 static const int c = 1; \
2545 static constexpr int d = 5;
2547 #if defined(FIRST) || defined(SECOND)
2551 #if defined(FIRST) || defined(SECOND)
2559 #if defined(FIRST) || defined(SECOND)
2566 // expected-error@second.h:* {{'VarDecl::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2567 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2570 } // namespace VarDecl
2578 #elif defined(SECOND)
2585 // expected-error@second.h:* {{'Friend::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'T1'}}
2586 // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T1'}}
2594 #elif defined(SECOND)
2601 // expected-error@second.h:* {{'Friend::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'struct T2'}}
2602 // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T2'}}
2610 #elif defined(SECOND)
2616 // expected-error@second.h:* {{'Friend::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function}}
2617 // expected-note@first.h:* {{but in 'FirstModule' found friend class}}
2624 #elif defined(SECOND)
2630 // expected-error@second.h:* {{'Friend::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function 'T5b'}}
2631 // expected-note@first.h:* {{but in 'FirstModule' found friend function 'T5a'}}
2635 friend class FriendA; \
2636 friend struct FriendB; \
2638 friend void Function();
2640 #if defined(FIRST) || defined(SECOND)
2646 #if defined(FIRST) || defined(SECOND)
2654 #if defined(FIRST) || defined(SECOND)
2661 // expected-error@second.h:* {{'Friend::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2662 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2665 } // namespace Friend
2667 namespace TemplateParameters
{
2671 #elif defined(SECOND)
2675 using TemplateParameters::S1
;
2676 // expected-error@second.h:* {{'TemplateParameters::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter 'B'}}
2677 // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}}
2681 template <class A
= double>
2683 #elif defined(SECOND)
2684 template <class A
= int>
2687 using TemplateParameters::S2
;
2688 // 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}}
2689 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2693 template <class A
= int>
2695 #elif defined(SECOND)
2699 using TemplateParameters::S3
;
2700 // 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}}
2701 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with default argument}}
2707 #elif defined(SECOND)
2708 template <int A
= 2>
2711 using TemplateParameters::S4
;
2712 // 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}}
2713 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with no default argument}}
2717 template <int> class S5_first
{};
2718 template <template<int> class A
= S5_first
>
2720 #elif defined(SECOND)
2721 template <int> class S5_second
{};
2722 template <template<int> class A
= S5_second
>
2725 using TemplateParameters::S5
;
2726 // 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}}
2727 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2733 #elif defined(SECOND)
2737 using TemplateParameters::S6
;
2738 // expected-error@second.h:* {{'TemplateParameters::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found unnamed template parameter}}
2739 // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}}
2743 template <int A
= 7>
2745 #elif defined(SECOND)
2746 template <int A
= 8>
2749 using TemplateParameters::S7
;
2750 // expected-error@second.h:* {{'TemplateParameters::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}}
2751 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2755 template <int* A
= nullptr>
2757 #elif defined(SECOND)
2758 inline int S8_default_arg
= 0x12345;
2759 template <int* A
= &S8_default_arg
>
2762 using TemplateParameters::S8
;
2763 // expected-error@second.h:* {{'TemplateParameters::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}}
2764 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2768 template <int A
= 43>
2770 #elif defined(SECOND)
2771 template <int A
= 43>
2774 using TemplateParameters::S9
;
2778 template <class A
= double>
2780 #elif defined(SECOND)
2781 template <class A
= double>
2784 using TemplateParameters::S10
;
2788 template <template<int> class A
= S9
>
2790 #elif defined(SECOND)
2791 template <template<int> class A
= S9
>
2794 using TemplateParameters::S11
;
2797 // FIXME: It looks like we didn't implement ODR check for template variables.
2798 // S12, S13 and S14 show this.
2800 template <int A
= 43>
2802 #elif defined(SECOND)
2803 template <int A
= 44>
2806 using TemplateParameters::S12
;
2810 template <class A
= double>
2812 #elif defined(SECOND)
2813 template <class A
= int>
2816 using TemplateParameters::S13
;
2822 #elif defined(SECOND)
2826 using TemplateParameters::S14
;
2831 #if defined(FIRST) || defined(SECOND)
2832 template <class> class DefaultArg
;
2835 #if defined(FIRST) || defined(SECOND)
2836 template <int, class, template <class> class,
2837 int A
, class B
, template <int> class C
,
2838 int D
= 1, class E
= int, template <class F
> class = DefaultArg
>
2843 using TemplateParameters::Valid1
;
2846 #if defined(FIRST) || defined(SECOND)
2847 template <int, class, template <class> class,
2848 int A
, class B
, template <int> class C
,
2849 int D
= 1, class E
= int, template <class F
> class = DefaultArg
>
2855 using TemplateParameters::Invalid1
;
2856 // expected-error@second.h:* {{'TemplateParameters::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2857 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2860 } // namespace TemplateParameters
2862 namespace BaseClass
{
2866 #elif defined(SECOND)
2870 // expected-error@second.h:* {{'BaseClass::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 base classes}}
2871 // expected-note@first.h:* {{but in 'FirstModule' found 1 base class}}
2876 #elif defined(SECOND)
2878 struct S2
: virtual B2
{};
2881 // expected-error@second.h:* {{'BaseClass::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 base class}}
2882 // expected-note@first.h:* {{but in 'FirstModule' found 0 base classes}}
2888 #elif defined(SECOND)
2890 struct S3
: virtual B3b
{};
2893 // expected-error@second.h:* {{'BaseClass::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}}
2894 // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}}
2900 #elif defined(SECOND)
2905 // 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 'B4b'}}
2906 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class with different type 'B4a'}}
2911 struct S5
: virtual B5a
{};
2912 #elif defined(SECOND)
2917 // expected-error@second.h:* {{'BaseClass::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 virtual base classes}}
2918 // expected-note@first.h:* {{but in 'FirstModule' found 1 virtual base class}}
2924 #elif defined(SECOND)
2926 struct S6
: virtual B6a
{};
2929 // expected-error@second.h:* {{'BaseClass::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}}
2930 // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}}
2935 struct S7
: protected B7a
{};
2936 #elif defined(SECOND)
2941 // expected-error@second.h:* {{'BaseClass::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'B7a' with no access specifier}}
2942 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B7a' with protected access specifier}}
2947 struct S8
: public B8a
{};
2948 #elif defined(SECOND)
2950 struct S8
: private B8a
{};
2953 // expected-error@second.h:* {{'BaseClass::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'B8a' with private access specifier}}
2954 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B8a' with public access specifier}}
2959 struct S9
: private B9a
{};
2960 #elif defined(SECOND)
2962 struct S9
: public B9a
{};
2965 // expected-error@second.h:* {{'BaseClass::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'B9a' with public access specifier}}
2966 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B9a' with private access specifier}}
2971 struct S10
: B10a
{};
2972 #elif defined(SECOND)
2974 struct S10
: protected B10a
{};
2977 // expected-error@second.h:* {{'BaseClass::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'B10a' with protected access specifier}}
2978 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B10a' with no access specifier}}
2983 #if defined(FIRST) || defined(SECOND)
2991 #if defined(FIRST) || defined(SECOND)
2993 Base1
, virtual Base2
, protected Base3
, public Base4
, private Base5
{
3001 #if defined(FIRST) || defined(SECOND)
3003 Base1
, virtual Base2
, protected Base3
, public Base4
, private Base5
{
3010 // expected-error@second.h:* {{'BaseClass::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3011 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3014 } // namespace BaseClass
3016 namespace PointersAndReferences
{
3017 #if defined(FIRST) || defined(SECOND)
3018 template<typename
> struct Wrapper
{};
3025 #elif defined(SECOND)
3031 // expected-error@first.h:* {{PointersAndReferences::S1::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S1' in module 'SecondModule'}}
3032 // expected-note@second.h:* {{declaration of 'x' does not match}}
3039 #elif defined(SECOND)
3041 Wrapper
<float &&> x
;
3045 // expected-error@first.h:* {{PointersAndReferences::S2::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S2' in module 'SecondModule'}}
3046 // expected-note@second.h:* {{declaration of 'x' does not match}}
3053 #elif defined(SECOND)
3059 // expected-error@first.h:* {{PointersAndReferences::S3::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S3' in module 'SecondModule'}}
3060 // expected-note@second.h:* {{declaration of 'x' does not match}}
3067 #elif defined(SECOND)
3073 // expected-error@first.h:* {{PointersAndReferences::S4::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S4' in module 'SecondModule'}}
3074 // expected-note@second.h:* {{declaration of 'x' does not match}}
3081 #elif defined(SECOND)
3083 Wrapper
<const S5
*> x
;
3087 // expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 'SecondModule' is not present in definition of 'PointersAndReferences::S5' in module 'FirstModule'}}
3088 // expected-note@first.h:* {{declaration of 'x' does not match}}
3095 #elif defined(SECOND)
3097 Wrapper
<const int &> x
;
3101 // expected-error@first.h:* {{PointersAndReferences::S6::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S6' in module 'SecondModule'}}
3102 // expected-note@second.h:* {{declaration of 'x' does not match}}
3106 Wrapper<int *> x1; \
3107 Wrapper<float *> x2; \
3108 Wrapper<const float *> x3; \
3109 Wrapper<int &> x4; \
3110 Wrapper<int &&> x5; \
3111 Wrapper<const int &> x6; \
3116 #if defined(FIRST) || defined(SECOND)
3124 #if defined(FIRST) || defined(SECOND)
3131 // expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3132 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3135 } // namespace PointersAndReferences
3137 namespace FunctionTemplate
{
3140 template <int, int> void foo();
3142 #elif defined(SECOND)
3144 template <int> void foo();
3148 // expected-error@first.h:* {{'FunctionTemplate::S1::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S1' in module 'SecondModule'}}
3149 // expected-note@second.h:* {{declaration of 'foo' does not match}}
3154 template <char> void foo();
3156 #elif defined(SECOND)
3158 template <int> void foo();
3162 // expected-error@first.h:* {{'FunctionTemplate::S2::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S2' in module 'SecondModule'}}
3163 // expected-note@second.h:* {{declaration of 'foo' does not match}}
3168 template <int x
> void foo();
3170 #elif defined(SECOND)
3172 template <int y
> void foo();
3176 // 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'}}
3177 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}}
3182 template <int x
> void foo();
3184 #elif defined(SECOND)
3186 template <int x
> void bar();
3190 // expected-error@first.h:* {{'FunctionTemplate::S4::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S4' in module 'SecondModule'}}
3191 // expected-note@second.h:* {{definition has no member 'foo'}}
3196 template <int x
> void foo();
3198 #elif defined(SECOND)
3201 template <int x
> void foo();
3205 // expected-error@second.h:* {{'FunctionTemplate::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3206 // expected-note@first.h:* {{but in 'FirstModule' found function template}}
3211 template <typename x
= int> void foo();
3213 #elif defined(SECOND)
3215 template <typename x
> void foo();
3219 // 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}}
3220 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
3225 template <typename x
= void> void foo();
3227 #elif defined(SECOND)
3229 template <typename x
= int> void foo();
3233 // 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'}}
3234 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'void'}}
3241 template <template<int> class x
= U8
> void foo();
3243 #elif defined(SECOND)
3247 template <template<int> class x
= T8
> void foo();
3251 // 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'}}
3252 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'U8'}}
3259 template <template<int> class x
= U9
> void foo();
3261 #elif defined(SECOND)
3263 template <template<int> class x
> void foo();
3267 // 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}}
3268 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
3273 template <template<int> class x
> void foo();
3274 template <template<typename
> class x
> void foo();
3276 #elif defined(SECOND)
3278 template <template<typename
> class x
> void foo();
3279 template <template<int> class x
> void foo();
3283 // 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}}
3284 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}}
3289 template <template<int> class x
> void foo();
3291 #elif defined(SECOND)
3293 template <template<int> class> void foo();
3297 // 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}}
3298 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}}
3303 template <class> void foo();
3304 template <class, class> void foo();
3306 #elif defined(SECOND)
3308 template <class, class> void foo();
3309 template <class> void foo();
3313 // 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}}
3314 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1 template parameter}}
3319 template <class = int> void foo();
3321 #elif defined(SECOND)
3323 template <class = void> void foo();
3327 // 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'}}
3328 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'int'}}
3333 template <class = void> void foo();
3335 #elif defined(SECOND)
3337 template <class> void foo();
3341 // 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}}
3342 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
3347 template <class> void foo();
3349 #elif defined(SECOND)
3351 template <class = void> void foo();
3355 // 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}}
3356 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}}
3361 template <short> void foo();
3363 #elif defined(SECOND)
3365 template <short = 1> void foo();
3369 // 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}}
3370 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}}
3375 template <short = 2> void foo();
3377 #elif defined(SECOND)
3379 template <short = 1 + 1> void foo();
3383 // 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}}
3384 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 2}}
3389 template <short> void foo();
3390 template <int> void foo();
3392 #elif defined(SECOND)
3394 template <int> void foo();
3395 template <short> void foo();
3399 // 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}}
3400 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}}
3405 template <short> void foo();
3406 template <short...> void foo();
3408 #elif defined(SECOND)
3410 template <short...> void foo();
3411 template <short> void foo();
3415 // 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}}
3416 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}}
3421 template <class> void foo();
3422 template <class...> void foo();
3424 #elif defined(SECOND)
3426 template <class...> void foo();
3427 template <class> void foo();
3431 // 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}}
3432 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}}
3437 template <template<class> class...> void foo();
3438 template <template<class> class> void foo();
3440 #elif defined(SECOND)
3442 template <template<class> class> void foo();
3443 template <template<class> class...> void foo();
3447 // 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}}
3448 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter being a template parameter pack}}
3453 template <template<class> class> void foo();
3454 template <class> void foo();
3455 template <int> void foo();
3457 #elif defined(SECOND)
3459 template <class> void foo();
3460 template <int> void foo();
3461 template <template<class> class> void foo();
3465 // 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}}
3466 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a template template parameter}}
3471 template <class> void foo();
3472 template <int> void foo();
3473 template <template<class> class> void foo();
3475 #elif defined(SECOND)
3477 template <int> void foo();
3478 template <template<class> class> void foo();
3479 template <class> void foo();
3483 // 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}}
3484 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a type template parameter}}
3489 template <int> void foo();
3490 template <template<class> class> void foo();
3491 template <class> void foo();
3493 #elif defined(SECOND)
3495 template <template<class> class> void foo();
3496 template <class> void foo();
3497 template <int> void foo();
3501 // 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}}
3502 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a non-type template parameter}}
3507 template <int> void foo();
3509 #elif defined(SECOND)
3512 template <int> void foo();
3516 // expected-error@second.h:* {{'FunctionTemplate::S25' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3517 // expected-note@first.h:* {{but in 'FirstModule' found function template}}
3525 template <int, int> \
3527 template <int x = 5> \
3529 template <int... x> \
3534 template <class x> \
3536 template <class, class> \
3538 template <class x = int> \
3540 template <class... x> \
3543 template <template <int> class> \
3545 template <template <int> class x> \
3547 template <template <int> class, template <int> class> \
3549 template <template <int> class x = U> \
3551 template <template <int> class... x> \
3554 #if defined(FIRST) || defined(SECOND)
3564 #if defined(FIRST) || defined(SECOND)
3571 // expected-error@second.h:* {{'FunctionTemplate::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3572 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3580 #elif defined(SECOND)
3584 // expected-error@first.h:* {{'Enums::x11' from module 'FirstModule' is not present in definition of 'Enums::E1' in module 'SecondModule'}}
3585 // expected-note@second.h:* {{definition has no member 'x11'}}
3590 #elif defined(SECOND)
3594 // expected-error@second.h:* {{'Enums::E2' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 1 element}}
3595 // expected-note@first.h:* {{but in 'FirstModule' found enum with 0 elements}}
3600 #elif defined(SECOND)
3604 // expected-error@first.h:* {{'Enums::x31' from module 'FirstModule' is not present in definition of 'Enums::E3' in module 'SecondModule'}}
3605 // expected-note@second.h:* {{definition has no member 'x31'}}
3610 #elif defined(SECOND)
3611 enum E4
{ x41
, x42
};
3614 // expected-error@second.h:* {{'Enums::E4' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 2 elements}}
3615 // expected-note@first.h:* {{but in 'FirstModule' found enum with 1 element}}
3619 enum E5
{ x51
, x52
};
3620 #elif defined(SECOND)
3624 // expected-error@first.h:* {{'Enums::x52' from module 'FirstModule' is not present in definition of 'Enums::E5' in module 'SecondModule'}}
3625 // expected-note@second.h:* {{definition has no member 'x52'}}
3629 enum E6
{ x61
, x62
};
3630 #elif defined(SECOND)
3631 enum E6
{ x62
, x61
};
3634 // expected-error@second.h:* {{'Enums::E6' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element has name 'x62'}}
3635 // expected-note@first.h:* {{but in 'FirstModule' found 1st element has name 'x61'}}
3639 enum E7
{ x71
= 0 };
3640 #elif defined(SECOND)
3644 // expected-error@second.h:* {{'Enums::E7' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element 'x71' has an initializer}}
3645 // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x71' does not have an initializer}}
3650 #elif defined(SECOND)
3651 enum E8
{ x81
= 0 };
3654 // 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 initializer}}
3655 // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x81' has an initializer}}
3659 enum E9
{ x91
= 0, x92
= 1 };
3660 #elif defined(SECOND)
3661 enum E9
{ x91
= 0, x92
= 2 - 1 };
3664 // 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}}
3665 // expected-note@first.h:* {{but in 'FirstModule' found 2nd element 'x92' has different initializer}}
3669 enum class E10
: int {};
3670 #elif defined(SECOND)
3674 // expected-error@second.h:* {{'Enums::E10' has different definitions in different modules; definition in module 'SecondModule' first difference is enum without specified type}}
3675 // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type}}
3680 #elif defined(SECOND)
3684 // expected-error@second.h:* {{'Enums::E11' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type}}
3685 // expected-note@first.h:* {{but in 'FirstModule' found enum without specified type}}
3689 enum struct E12
: long {};
3690 #elif defined(SECOND)
3691 enum struct E12
: int {};
3694 // expected-error@second.h:* {{'Enums::E12' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type 'int'}}
3695 // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type 'long'}}
3700 #elif defined(SECOND)
3704 // expected-error@second.h:* {{'Enums::E13' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is not scoped}}
3705 // expected-note@first.h:* {{but in 'FirstModule' found enum that is scoped}}
3710 #elif defined(SECOND)
3714 // expected-error@second.h:* {{'Enums::E14' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is scoped}}
3715 // expected-note@first.h:* {{but in 'FirstModule' found enum that is not scoped}}
3720 #elif defined(SECOND)
3724 // expected-error@second.h:* {{'Enums::E15' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword struct}}
3725 // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword class}}
3730 #elif defined(SECOND)
3734 // expected-error@second.h:* {{'Enums::E16' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword class}}
3735 // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword struct}}
3739 enum Valid
{ v1
= (struct S
*)0 == (struct S
*)0 };
3740 #elif defined(SECOND)
3742 enum Valid
{ v1
= (struct S
*)0 == (struct S
*)0 };
3746 } // namespace Enums
3757 #elif defined(SECOND)
3765 auto function1
= invalid
;
3766 // expected-error@second.h:* {{'Types::Complex::invalid' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3767 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3768 auto function2
= valid
;
3770 } // namespace Complex
3772 namespace Decltype
{
3785 #elif defined(SECOND)
3798 auto function1
= invalid1
;
3799 // expected-error@second.h:* {{'Types::Decltype::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3800 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3801 auto function2
= invalid2
;
3802 // FIXME: We should reject the merge of `invalid2` and diagnose about the
3803 // inconsistent definition of `global`.
3804 auto function3
= valid
;
3806 } // namespace Decltype
3811 decltype(auto) x
= 1;
3820 decltype(auto) x
= 1;
3824 #elif defined(SECOND)
3832 decltype(auto) x
= 1;
3835 decltype(auto) x
= 1;
3840 auto function1
= invalid1
;
3841 // expected-error@second.h:* {{'Types::Auto::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3842 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3843 auto function2
= invalid3
;
3844 // expected-error@second.h:* {{'Types::Auto::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3845 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3846 auto function3
= invalid2
;
3847 // expected-error@second.h:* {{'Types::Auto::invalid3' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3848 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3849 auto function4
= valid
;
3853 namespace DeducedTemplateSpecialization
{
3855 template<typename T
> struct A
{};
3857 template<typename T
> struct B
{};
3869 #elif defined(SECOND)
3870 template<typename T
> struct A
{};
3872 template<typename T
> struct B
{};
3885 auto function1
= invalid1
;
3886 // FIXME: We should reject the merge of `invalid1` due to the inconsistent definition.
3887 auto function2
= invalid2
;
3888 // expected-error@second.h:* {{'Types::DeducedTemplateSpecialization::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3889 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3890 auto function3
= valid
;
3892 } // namespace DeducedTemplateSpecialization
3894 namespace DependentAddressSpace
{
3896 template <int A1
, int A2
>
3898 using type
= int __attribute__((address_space(A1
)));
3902 using type
= float __attribute__((address_space(A1
)));
3904 template <int A1
, int A2
>
3906 using type1
= float __attribute__((address_space(A1
)));
3907 using type2
= int __attribute__((address_space(A2
)));
3908 using type3
= int __attribute__((address_space(A1
+ A2
)));
3910 #elif defined(SECOND)
3911 template <int A1
, int A2
>
3913 using type
= int __attribute__((address_space(A2
)));
3917 using type
= int __attribute__((address_space(A1
)));
3919 template <int A1
, int A2
>
3921 using type1
= float __attribute__((address_space(A1
)));
3922 using type2
= int __attribute__((address_space(A2
)));
3923 using type3
= int __attribute__((address_space(A1
+ A2
)));
3926 template <int A
, int B
>
3928 static auto function1
= invalid1
<A
, B
>;
3929 // expected-error@first.h:* {{'Types::DependentAddressSpace::invalid1' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3930 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3931 static auto function2
= invalid2
<B
>;
3932 // expected-error@first.h:* {{'Types::DependentAddressSpace::invalid2' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3933 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3934 static auto function3
= valid
<A
, B
>;
3937 } // namespace DependentAddressSpace
3939 namespace DependentSizedExtVector
{
3943 typedef int __attribute__((ext_vector_type(Size
))) type
;
3947 typedef int __attribute__((ext_vector_type(Size
+ 0))) type
;
3951 typedef int __attribute__((ext_vector_type(Size
))) type
;
3953 #elif defined(SECOND)
3956 typedef float __attribute__((ext_vector_type(Size
))) type
;
3960 typedef int __attribute__((ext_vector_type(Size
+ 1))) type
;
3964 typedef int __attribute__((ext_vector_type(Size
))) type
;
3969 static auto Function1
= invalid1
<Num
>;
3970 // expected-error@first.h:* {{'Types::DependentSizedExtVector::invalid1' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3971 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3972 static auto Function2
= invalid2
<Num
>;
3973 // expected-error@first.h:* {{'Types::DependentSizedExtVector::invalid2' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3974 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3975 static auto Function3
= valid
<Num
>;
3978 } // namespace DependentSizedExtVector
3980 namespace InjectedClassName
{
4001 #elif defined(SECOND)
4022 Invalid::L2
<1>::L3
<1> invalid
;
4023 // expected-error@second.h:* {{'Types::InjectedClassName::Invalid::L2::L3::x' from module 'SecondModule' is not present in definition of 'L3<>' in module 'FirstModule'}}
4024 // expected-note@first.h:* {{declaration of 'x' does not match}}
4025 Valid::L2
<1>::L3
<1> valid
;
4027 } // namespace InjectedClassName
4029 namespace MemberPointer
{
4049 void (B::*fun3
)(int);
4050 void (B::*fun4
)(bool*, int);
4052 #elif defined(SECOND)
4063 int (A::*x
)(int, int);
4071 void (B::*fun3
)(int);
4072 void (B::*fun4
)(bool*, int);
4075 auto function1
= Invalid1
;
4076 // expected-error@second.h:* {{'Types::MemberPointer::Invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4077 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4078 auto function2
= Invalid2
;
4079 // expected-error@second.h:* {{'Types::MemberPointer::Invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4080 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4081 auto function3
= Invalid3
;
4082 // expected-error@second.h:* {{'Types::MemberPointer::Invalid3' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4083 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4084 auto function4
= Valid
;
4087 } // namespace MemberPointer
4089 namespace PackExpansion
{
4092 template <class... A
>
4094 template <class... B
>
4102 template <class... A
>
4104 template <class... B
>
4111 #elif defined(SECOND)
4113 template <class... A
>
4115 template <class... B
>
4123 template <class... A
>
4125 template <class... B
>
4133 Invalid::L2
<int>::L3
<short, bool> invalid
;
4134 // expected-error@first.h:* {{'Types::PackExpansion::Invalid::L2::L3' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'run' with 1st parameter of type 'A...'}}
4135 // expected-note@second.h:* {{but in 'SecondModule' found method 'run' with 1st parameter of type 'B...'}}
4136 Valid::L2
<int>::L3
<short, bool> valid
;
4139 } // namespace PackExpansion
4149 #elif defined(SECOND)
4157 auto function1
= invalid
;
4158 // expected-error@second.h:* {{'Types::Paren::invalid' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4159 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4160 auto function2
= valid
;
4162 } // namespace Paren
4164 namespace SubstTemplateTypeParm
{
4166 template <class> struct wrapper
{};
4167 template <class, class, class> struct triple
{};
4170 template <class _T
, class _U
, class = wrapper
<_T
>> class A
= triple
>
4175 #elif defined(SECOND)
4176 template <class> struct wrapper
{};
4177 template <class, class, class> struct triple
{};
4180 template <class _T
, class _U
, class = wrapper
<_T
>> class A
= triple
>
4187 template <class _T
, class _U
, class = wrapper
<_T
>> class A
= triple
>
4188 using V
= Valid::L2
<T
, A
>;
4190 } // namespace SubstTemplateTypeParm
4192 namespace SubstTemplateTypeParmPack
{
4193 } // namespace SubstTemplateTypeParmPack
4195 namespace UnaryTransform
{
4197 enum class E1a
: unsigned {};
4199 __underlying_type(E1a
) x
;
4201 enum E2a
: unsigned {};
4203 __underlying_type(E2a
) x
;
4207 __underlying_type(E3a
) x
;
4211 __underlying_type(E4a
) x
;
4215 __underlying_type(E1
) x
;
4217 enum E2
: unsigned {};
4219 __underlying_type(E2
) x
;
4223 __underlying_type(E3
) x
;
4225 #elif defined(SECOND)
4226 enum class E1b
: signed {};
4228 __underlying_type(E1b
) x
;
4230 enum class E2b
: unsigned {};
4232 __underlying_type(E2b
) x
;
4236 __underlying_type(E3b
) x
;
4240 __underlying_type(E4b
) x
;
4244 // expected-error@first.h:* {{'Types::UnaryTransform::Invalid1::x' from module 'FirstModule' is not present in definition of 'Types::UnaryTransform::Invalid1' in module 'SecondModule'}}
4245 // expected-note@second.h:* {{declaration of 'x' does not match}}
4247 // expected-error@second.h:* {{'Types::UnaryTransform::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type '__underlying_type(E2b)' (aka 'unsigned int')}}
4248 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type '__underlying_type(E2a)' (aka 'unsigned int')}}
4250 // expected-error@first.h:* {{'Types::UnaryTransform::Invalid3::x' from module 'FirstModule' is not present in definition of 'Types::UnaryTransform::Invalid3' in module 'SecondModule'}}
4251 // expected-note@second.h:* {{declaration of 'x' does not match}}
4253 // expected-error@second.h:* {{'Types::UnaryTransform::Invalid4' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type '__underlying_type(E4b)' (aka 'unsigned int')}}
4254 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type '__underlying_type(E4a)' (aka 'unsigned int')}}
4259 } // namespace UnaryTransform
4261 namespace UnresolvedUsing
{
4263 template <class T
> struct wrapper
{};
4266 using typename wrapper
<T
>::T1
;
4267 using typename wrapper
<T
>::T2
;
4272 using typename wrapper
<T
>::T1
;
4273 using typename wrapper
<T
>::T2
;
4277 #elif defined(SECOND)
4278 template <class T
> struct wrapper
{};
4281 using typename wrapper
<T
>::T1
;
4282 using typename wrapper
<T
>::T2
;
4287 using typename wrapper
<T
>::T1
;
4288 using typename wrapper
<T
>::T2
;
4293 template <class T
> using I
= Invalid
<T
>;
4294 // expected-error@first.h:* {{'Types::UnresolvedUsing::Invalid::x' from module 'FirstModule' is not present in definition of 'Invalid<T>' in module 'SecondModule'}}
4295 // expected-note@second.h:* {{declaration of 'x' does not match}}
4297 template <class T
> using V
= Valid
<T
>;
4300 } // namespace UnresolvedUsing
4303 // void invalid1() {
4304 // __attribute((vector_size(8))) int *x1;
4307 } // namespace Types
4309 // Collection of interesting cases below.
4311 // Naive parsing of AST can lead to cycles in processing. Ensure
4312 // self-references don't trigger an endless cycles of AST node processing.
4313 namespace SelfReference
{
4315 template <template <int> class T
> class Wrapper
{};
4317 template <int N
> class S
{
4318 S(Wrapper
<::SelfReference::S
> &Ref
) {}
4329 template <typename
> struct Foo
;
4330 template <template <class> class T
= NNS::Foo
>
4331 struct NestedNamespaceSpecifier
{};
4334 } // namespace SelfReference
4336 namespace FriendFunction
{
4339 struct S
{ friend void F(int); };
4340 #elif defined(SECOND)
4342 struct S
{ friend void F(int); };
4354 #elif defined(SECOND)
4363 // expected-error@second.h:* {{'FriendFunction::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
4364 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
4366 } // namespace FriendFunction
4368 namespace ImplicitDecl
{
4371 void S_Constructors() {
4372 // Trigger creation of implicit contructors
4377 #elif defined(SECOND)
4387 void T_Constructors() {
4388 // Trigger creation of implicit contructors
4393 #elif defined(SECOND)
4399 // expected-error@first.h:* {{'ImplicitDecl::T' has different definitions in different modules; first difference is definition in module 'FirstModule' found private access specifier}}
4400 // expected-note@second.h:* {{but in 'SecondModule' found public access specifier}}
4403 } // namespace ImplicitDecl
4405 namespace TemplatedClass
{
4409 #elif defined(SECOND)
4421 #elif defined(SECOND)
4428 // expected-error@second.h:* {{'TemplatedClass::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
4429 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
4431 } // namespace TemplatedClass
4433 namespace TemplateClassWithField
{
4439 #elif defined(SECOND)
4455 #elif defined(SECOND)
4464 // expected-error@second.h:* {{'TemplateClassWithField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
4465 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
4467 } // namespace TemplateClassWithField
4469 namespace TemplateClassWithTemplateField
{
4477 #elif defined(SECOND)
4499 #elif defined(SECOND)
4512 // expected-error@second.h:* {{'TemplateClassWithTemplateField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4513 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4515 } // namespace TemplateClassWithTemplateField
4517 namespace EnumWithForwardDeclaration
{
4523 #elif defined(SECOND)
4524 enum E
: int { A
, B
};
4537 #elif defined(SECOND)
4544 // expected-error@second.h:* {{'EnumWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4545 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4547 } // namespace EnumWithForwardDeclaration
4549 namespace StructWithForwardDeclaration
{
4555 #elif defined(SECOND)
4569 #elif defined(SECOND)
4576 // expected-error@second.h:* {{'StructWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4577 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4579 } // namespace StructWithForwardDeclaration
4581 namespace StructWithForwardDeclarationNoDefinition
{
4587 #elif defined(SECOND)
4602 #elif defined(SECOND)
4610 // expected-error@second.h:* {{'StructWithForwardDeclarationNoDefinition::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4611 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4613 } // namespace StructWithForwardDeclarationNoDefinition
4615 namespace LateParsedDefaultArgument
{
4617 template <typename T
>
4620 void foo(T x
= 0) {}
4623 #elif defined(SECOND)
4629 } // namespace LateParsedDefaultArgument
4631 namespace LateParsedDefaultArgument
{
4633 template <typename alpha
> struct Bravo
{
4634 void charlie(bool delta
= false) {}
4636 typedef Bravo
<char> echo
;
4640 #elif defined(SECOND)
4643 } // LateParsedDefaultArgument
4645 namespace DifferentParameterNameInTemplate
{
4646 #if defined(FIRST) || defined(SECOND)
4647 template <typename T
>
4651 static void Run(const Type
*name_one
);
4654 template <typename T
>
4655 void S
<T
>::Run(const T
*name_two
) {}
4657 template <typename T
>
4659 ~Foo() { Handler::Run(nullptr); }
4662 class Handler
: public S
<T
> {};
4664 void Get(typename
Handler::Type
*x
= nullptr) {}
4665 void Add() { Handler::Run(nullptr); }
4674 void Go() { betas
.Get(); }
4678 #elif defined(SECOND)
4682 void add_Beta() { betas
.Add(); }
4689 } // DifferentParameterNameInTemplate
4691 namespace ParameterTest
{
4694 template <typename G
>
4698 static inline G
*Foo(const G
*a
, int * = nullptr);
4701 template<typename G
>
4702 G
* S
<G
>::Foo(const G
* aaaa
, int*) {}
4703 #elif defined(SECOND)
4704 template <typename G
>
4708 static inline G
*Foo(const G
*a
, int * = nullptr);
4711 template<typename G
>
4712 G
* S
<G
>::Foo(const G
* asdf
, int*) {}
4715 // expected-error@first.h:* {{'ParameterTest::S::Foo' has different definitions in different modules; definition in module 'FirstModule' first difference is 1st parameter with name 'aaaa'}}
4716 // expected-note@second.h:* {{but in 'SecondModule' found 1st parameter with name 'asdf'}}
4720 namespace MultipleTypedefs
{
4727 #elif defined(SECOND)
4737 struct T2
{ int x
; };
4743 #elif defined(SECOND)
4744 struct T2
{ int x
; };
4754 using A3
= const int;
4755 using B3
= volatile A3
;
4759 #elif defined(SECOND)
4760 using A3
= volatile const int;
4775 #elif defined(SECOND)
4777 using B4
= ::MultipleTypedefs::A4
;
4787 using B5
= MultipleTypedefs::A5
;
4791 #elif defined(SECOND)
4793 using B5
= ::MultipleTypedefs::A5
;
4800 } // MultipleTypedefs
4802 namespace DefaultArguments
{
4804 template <typename T
>
4810 #elif defined(SECOND)
4811 template <typename T
>
4821 // 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}}
4822 // expected-note@first.h:* {{but in 'FirstModule' found method 'foo' with 1st parameter with a different default argument}}
4826 template <typename alpha
> struct Bravo
{
4827 void charlie(bool delta
= false);
4829 typedef Bravo
<char> echo
;
4831 #elif defined(SECOND)
4832 template <typename alpha
> struct Bravo
{
4833 void charlie(bool delta
= (false));
4835 typedef Bravo
<char> echo
;
4839 // 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}}
4840 // expected-note@first.h:* {{but in 'FirstModule' found method 'charlie' with 1st parameter with a different default argument}}
4842 } // namespace DefaultArguments
4844 namespace FunctionDecl
{
4848 #elif defined(SECOND)
4859 #elif defined(SECOND)
4872 #elif defined(SECOND)
4880 #if defined(FIRST) || defined(SECOND)
4881 int F1(int x
, float y
= 2.7) { return 1; }
4887 int F2() { return 1; }
4888 #elif defined(SECOND)
4889 double F2() { return 1; }
4892 // expected-error@-1 {{call to 'F2' is ambiguous}}
4893 // expected-note@first.h:* {{candidate function}}
4894 // expected-note@second.h:* {{candidate function}}
4898 int F3(float) { return 1; }
4899 #elif defined(SECOND)
4900 int F3(double) { return 1; }
4903 // expected-error@-1 {{call to 'F3' is ambiguous}}
4904 // expected-note@first.h:* {{candidate function}}
4905 // expected-note@second.h:* {{candidate function}}
4909 int F4(int x
) { return 1; }
4910 #elif defined(SECOND)
4911 int F4(int y
) { return 1; }
4914 // expected-error@second.h:* {{'FunctionDecl::F4' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with name 'y'}}
4915 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with name 'x'}}
4919 int F5(int x
) { return 1; }
4920 #elif defined(SECOND)
4921 int F5(int x
= 1) { return 1; }
4924 // 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}}
4925 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a default argument}}
4929 int F6(int x
= 2) { return 1; }
4930 #elif defined(SECOND)
4931 int F6(int x
= 1) { return 1; }
4934 // 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}}
4935 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a different default argument}}
4940 I
F7() { return 0; }
4941 #elif defined(SECOND)
4942 int F7() { return 0; }
4945 // expected-error@second.h:* {{'FunctionDecl::F7' has different definitions in different modules; definition in module 'SecondModule' first difference is return type is 'int'}}
4946 // expected-note@first.h:* {{but in 'FirstModule' found different return type 'I' (aka 'int')}}
4950 int F8(int) { return 0; }
4951 #elif defined(SECOND)
4952 int F8(I
) { return 0; }
4955 // expected-error@second.h:* {{'FunctionDecl::F8' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with type 'I' (aka 'int')}}
4956 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int'}}
4960 int F9(int[1]) { return 0; }
4961 #elif defined(SECOND)
4962 int F9(int[2]) { return 0; }
4964 int I9
= F9(nullptr);
4965 // 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]'}}
4966 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int *' decayed from 'int[1]'}}
4970 int F10() { return 1; }
4971 #elif defined(SECOND)
4972 int F10() { return 2; }
4976 // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4977 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4981 template <int> void foo();
4983 #elif defined(SECOND)
4985 template <int> void foo();
4987 template <int> void S11::foo() {}
4996 #elif defined(SECOND)
5000 void S12::foo(int y
) {}
5009 void S13::foo(int y
) {}
5010 #elif defined(SECOND)
5014 void S13::foo(int y
) {}
5018 } // namespace FunctionDecl
5020 namespace DeclTemplateArguments
{
5022 int foo() { return 1; }
5023 int bar() { return foo(); }
5024 #elif defined(SECOND)
5025 template <class T
= int>
5026 int foo() { return 2; }
5027 int bar() { return foo
<>(); }
5030 // expected-error@second.h:* {{'DeclTemplateArguments::bar' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
5031 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
5035 namespace FunctionProtoTypeDecay
{
5041 #elif defined(SECOND)
5044 using Y
= X(X(X()));
5048 // expected-error@first.h:* {{'FunctionProtoTypeDecay::S1::Y' from module 'FirstModule' is not present in definition of 'FunctionProtoTypeDecay::S1' in module 'SecondModule'}}
5049 // expected-note@second.h:* {{declaration of 'Y' does not match}}
5056 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
5057 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
5058 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
5059 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
5065 #elif defined(SECOND)
5071 namespace TypedefStruct
{
5077 #elif defined(SECOND)
5078 typedef struct T1
{} T1
;
5089 const T2
* t
= nullptr;
5091 #elif defined(SECOND)
5092 typedef struct T2
{} T2
;
5094 const T2
* t
= nullptr;
5103 T3
* const t
= nullptr;
5105 #elif defined(SECOND)
5106 typedef struct T3
{} T3
;
5108 T3
* const t
= nullptr;
5121 #elif defined(SECOND)
5123 typedef struct T4
{} T4
;
5139 #elif defined(SECOND)
5141 typedef struct T5_Other
{} T5
;
5148 // expected-error@first.h:* {{'TypedefStruct::S5::t' from module 'FirstModule' is not present in definition of 'TypedefStruct::S5' in module 'SecondModule'}}
5149 // expected-note@second.h:* {{declaration of 't' does not match}}
5151 } // namespace TypedefStruct
5158 #elif defined(SECOND)
5167 // Keep macros contained to one file.