1 // Clear and create directories
5 // RUN: mkdir %t/Inputs
7 // Build first header file
8 // RUN: echo "#define FIRST" >> %t/Inputs/first.h
9 // RUN: cat %s >> %t/Inputs/first.h
11 // Build second header file
12 // RUN: echo "#define SECOND" >> %t/Inputs/second.h
13 // RUN: cat %s >> %t/Inputs/second.h
15 // Test that each header can compile
16 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++1z %t/Inputs/first.h
17 // RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++1z %t/Inputs/second.h
19 // Build module map file
20 // RUN: echo "module FirstModule {" >> %t/Inputs/module.map
21 // RUN: echo " header \"first.h\"" >> %t/Inputs/module.map
22 // RUN: echo "}" >> %t/Inputs/module.map
23 // RUN: echo "module SecondModule {" >> %t/Inputs/module.map
24 // RUN: echo " header \"second.h\"" >> %t/Inputs/module.map
25 // RUN: echo "}" >> %t/Inputs/module.map
28 // RUN: %clang_cc1 -triple x86_64-linux-gnu -x c++ -std=c++1z \
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>(){};
2099 using c = OneClass<float>; \
2100 using d = OneInt<2>; \
2101 using e = OneInt<2 + 2>; \
2102 OneTemplateClass<OneClass> f; \
2103 OneTemplateInt<OneInt> g; \
2104 static int i1, i2; \
2106 void Function() {} \
2107 template <int &, int &> \
2108 void Function() {} \
2110 void Function<i1>() {} \
2112 void Function<i2>() {} \
2114 void Function<i1, i2>() {} \
2116 void Function<i2, i1>() {}
2118 #if defined(FIRST) || defined(SECOND)
2119 template <class> struct OneClass
{};
2120 template <int> struct OneInt
{};
2121 template <template <class> class> struct OneTemplateClass
{};
2122 template <template <int> class> struct OneTemplateInt
{};
2125 #if defined(FIRST) || defined(SECOND)
2133 #if defined(FIRST) || defined(SECOND)
2140 // expected-error@second.h:* {{'TemplateArgument::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2141 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2144 } // namespace TemplateArgument
2146 namespace TemplateTypeParmType
{
2148 template <class T1
, class T2
>
2152 #elif defined(SECOND)
2153 template <class T1
, class T2
>
2158 using TemplateTypeParmType::S1
;
2159 // expected-error@first.h:* {{'TemplateTypeParmType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T1, T2>' in module 'SecondModule'}}
2160 // expected-note@second.h:* {{declaration of 'x' does not match}}
2164 template <int ...Ts
>
2166 template <int T
, int U
>
2168 typedef U2
<U
, T
> type
;
2171 #elif defined(SECOND)
2172 template <int ...Ts
>
2174 template <int T
, int U
>
2176 typedef U2
<T
, U
> type
;
2180 using TemplateTypeParmType::S2
;
2181 // expected-error@first.h:* {{'TemplateTypeParmType::S2::x' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}}
2182 // expected-note@second.h:* {{declaration of 'x' does not match}}
2183 // expected-error@first.h:* {{'TemplateTypeParmType::S2::type' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}}
2184 // expected-note@second.h:* {{declaration of 'type' does not match}}
2190 ParameterPack<T> a; \
2191 ParameterPack<T, U> b; \
2192 ParameterPack<U> c; \
2193 ParameterPack<U, T> d;
2195 #if defined(FIRST) || defined(SECOND)
2196 template <class ...Ts
> struct ParameterPack
{};
2199 #if defined(FIRST) || defined(SECOND)
2200 template <class T
, class U
>
2205 using TemplateTypeParmType::Valid1
;
2208 #if defined(FIRST) || defined(SECOND)
2209 template <class T
, class U
>
2215 using TemplateTypeParmType::Invalid1
;
2216 // expected-error@second.h:* {{'TemplateTypeParmType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2217 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2220 } // namespace TemplateTypeParmType
2228 #elif defined(SECOND)
2235 // 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'}}
2236 // expected-note@first.h:* {{but in 'FirstModule' found data member with name 'x'}}
2243 #elif defined(SECOND)
2250 // 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')}}
2251 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with different type 'int'}}
2256 static const int x
= 1;
2258 #elif defined(SECOND)
2264 // 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}}
2265 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' without an initializer}}
2270 static const int x
= 1;
2272 #elif defined(SECOND)
2274 static const int x
= 2;
2278 // 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}}
2279 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with a different initializer}}
2284 static const int x
= 1;
2286 #elif defined(SECOND)
2288 static constexpr int x
= 1;
2292 // 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}}
2293 // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' is constexpr}}
2298 static const int x
= 1;
2300 #elif defined(SECOND)
2302 static const int y
= 1;
2306 // expected-error@first.h:* {{'VarDecl::S6::x' from module 'FirstModule' is not present in definition of 'VarDecl::S6' in module 'SecondModule'}}
2307 // expected-note@second.h:* {{definition has no member 'x'}}
2312 static const int x
= 1;
2314 #elif defined(SECOND)
2316 static const unsigned x
= 1;
2320 // expected-error@first.h:* {{'VarDecl::S7::x' from module 'FirstModule' is not present in definition of 'VarDecl::S7' in module 'SecondModule'}}
2321 // expected-note@second.h:* {{declaration of 'x' does not match}}
2327 static const int x
= 1;
2329 #elif defined(SECOND)
2331 static const int x
= 1;
2336 // expected-error@second.h:* {{'VarDecl::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member}}
2337 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2342 static const int x
= 1;
2344 #elif defined(SECOND)
2350 // expected-error@first.h:* {{'VarDecl::S9::x' from module 'FirstModule' is not present in definition of 'VarDecl::S9' in module 'SecondModule'}}
2351 // expected-note@second.h:* {{declaration of 'x' does not match}}
2357 static const int c = 1; \
2358 static constexpr int d = 5;
2360 #if defined(FIRST) || defined(SECOND)
2364 #if defined(FIRST) || defined(SECOND)
2372 #if defined(FIRST) || defined(SECOND)
2379 // expected-error@second.h:* {{'VarDecl::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2380 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2383 } // namespace VarDecl
2391 #elif defined(SECOND)
2398 // expected-error@second.h:* {{'Friend::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'T1'}}
2399 // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T1'}}
2407 #elif defined(SECOND)
2414 // expected-error@second.h:* {{'Friend::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'struct T2'}}
2415 // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T2'}}
2423 #elif defined(SECOND)
2429 // expected-error@second.h:* {{'Friend::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function}}
2430 // expected-note@first.h:* {{but in 'FirstModule' found friend class}}
2437 #elif defined(SECOND)
2443 // expected-error@second.h:* {{'Friend::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function 'T5b'}}
2444 // expected-note@first.h:* {{but in 'FirstModule' found friend function 'T5a'}}
2448 friend class FriendA; \
2449 friend struct FriendB; \
2451 friend void Function();
2453 #if defined(FIRST) || defined(SECOND)
2459 #if defined(FIRST) || defined(SECOND)
2467 #if defined(FIRST) || defined(SECOND)
2474 // expected-error@second.h:* {{'Friend::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2475 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2478 } // namespace Friend
2480 namespace TemplateParameters
{
2484 #elif defined(SECOND)
2488 using TemplateParameters::S1
;
2489 // expected-error@second.h:* {{'TemplateParameters::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter 'B'}}
2490 // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}}
2494 template <class A
= double>
2496 #elif defined(SECOND)
2497 template <class A
= int>
2500 using TemplateParameters::S2
;
2501 // 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}}
2502 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2506 template <class A
= int>
2508 #elif defined(SECOND)
2512 using TemplateParameters::S3
;
2513 // 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}}
2514 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with default argument}}
2520 #elif defined(SECOND)
2521 template <int A
= 2>
2524 using TemplateParameters::S4
;
2525 // 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}}
2526 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with no default argument}}
2530 template <int> class S5_first
{};
2531 template <template<int> class A
= S5_first
>
2533 #elif defined(SECOND)
2534 template <int> class S5_second
{};
2535 template <template<int> class A
= S5_second
>
2538 using TemplateParameters::S5
;
2539 // 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}}
2540 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2546 #elif defined(SECOND)
2550 using TemplateParameters::S6
;
2551 // expected-error@second.h:* {{'TemplateParameters::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found unnamed template parameter}}
2552 // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}}
2556 template <int A
= 7>
2558 #elif defined(SECOND)
2559 template <int A
= 8>
2562 using TemplateParameters::S7
;
2563 // 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}}
2564 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2568 template <int* A
= nullptr>
2570 #elif defined(SECOND)
2571 inline int S8_default_arg
= 0x12345;
2572 template <int* A
= &S8_default_arg
>
2575 using TemplateParameters::S8
;
2576 // 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}}
2577 // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}}
2581 template <int A
= 43>
2583 #elif defined(SECOND)
2584 template <int A
= 43>
2587 using TemplateParameters::S9
;
2591 template <class A
= double>
2593 #elif defined(SECOND)
2594 template <class A
= double>
2597 using TemplateParameters::S10
;
2601 template <template<int> class A
= S9
>
2603 #elif defined(SECOND)
2604 template <template<int> class A
= S9
>
2607 using TemplateParameters::S11
;
2610 // FIXME: It looks like we didn't implement ODR check for template variables.
2611 // S12, S13 and S14 show this.
2613 template <int A
= 43>
2615 #elif defined(SECOND)
2616 template <int A
= 44>
2619 using TemplateParameters::S12
;
2623 template <class A
= double>
2625 #elif defined(SECOND)
2626 template <class A
= int>
2629 using TemplateParameters::S13
;
2635 #elif defined(SECOND)
2639 using TemplateParameters::S14
;
2644 #if defined(FIRST) || defined(SECOND)
2645 template <class> class DefaultArg
;
2648 #if defined(FIRST) || defined(SECOND)
2649 template <int, class, template <class> class,
2650 int A
, class B
, template <int> class C
,
2651 int D
= 1, class E
= int, template <class F
> class = DefaultArg
>
2656 using TemplateParameters::Valid1
;
2659 #if defined(FIRST) || defined(SECOND)
2660 template <int, class, template <class> class,
2661 int A
, class B
, template <int> class C
,
2662 int D
= 1, class E
= int, template <class F
> class = DefaultArg
>
2668 using TemplateParameters::Invalid1
;
2669 // expected-error@second.h:* {{'TemplateParameters::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2670 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2673 } // namespace TemplateParameters
2675 namespace BaseClass
{
2679 #elif defined(SECOND)
2683 // expected-error@second.h:* {{'BaseClass::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 base classes}}
2684 // expected-note@first.h:* {{but in 'FirstModule' found 1 base class}}
2689 #elif defined(SECOND)
2691 struct S2
: virtual B2
{};
2694 // expected-error@second.h:* {{'BaseClass::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 base class}}
2695 // expected-note@first.h:* {{but in 'FirstModule' found 0 base classes}}
2701 #elif defined(SECOND)
2703 struct S3
: virtual B3b
{};
2706 // expected-error@second.h:* {{'BaseClass::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}}
2707 // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}}
2713 #elif defined(SECOND)
2718 // 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'}}
2719 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class with different type 'B4a'}}
2724 struct S5
: virtual B5a
{};
2725 #elif defined(SECOND)
2730 // expected-error@second.h:* {{'BaseClass::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 virtual base classes}}
2731 // expected-note@first.h:* {{but in 'FirstModule' found 1 virtual base class}}
2737 #elif defined(SECOND)
2739 struct S6
: virtual B6a
{};
2742 // expected-error@second.h:* {{'BaseClass::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}}
2743 // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}}
2748 struct S7
: protected B7a
{};
2749 #elif defined(SECOND)
2754 // 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}}
2755 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B7a' with protected access specifier}}
2760 struct S8
: public B8a
{};
2761 #elif defined(SECOND)
2763 struct S8
: private B8a
{};
2766 // 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}}
2767 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B8a' with public access specifier}}
2772 struct S9
: private B9a
{};
2773 #elif defined(SECOND)
2775 struct S9
: public B9a
{};
2778 // 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}}
2779 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B9a' with private access specifier}}
2784 struct S10
: B10a
{};
2785 #elif defined(SECOND)
2787 struct S10
: protected B10a
{};
2790 // 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}}
2791 // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'B10a' with no access specifier}}
2796 #if defined(FIRST) || defined(SECOND)
2804 #if defined(FIRST) || defined(SECOND)
2806 Base1
, virtual Base2
, protected Base3
, public Base4
, private Base5
{
2814 #if defined(FIRST) || defined(SECOND)
2816 Base1
, virtual Base2
, protected Base3
, public Base4
, private Base5
{
2823 // expected-error@second.h:* {{'BaseClass::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2824 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2827 } // namespace BaseClass
2829 namespace PointersAndReferences
{
2830 #if defined(FIRST) || defined(SECOND)
2831 template<typename
> struct Wrapper
{};
2838 #elif defined(SECOND)
2844 // expected-error@first.h:* {{PointersAndReferences::S1::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S1' in module 'SecondModule'}}
2845 // expected-note@second.h:* {{declaration of 'x' does not match}}
2852 #elif defined(SECOND)
2854 Wrapper
<float &&> x
;
2858 // expected-error@first.h:* {{PointersAndReferences::S2::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S2' in module 'SecondModule'}}
2859 // expected-note@second.h:* {{declaration of 'x' does not match}}
2866 #elif defined(SECOND)
2872 // expected-error@first.h:* {{PointersAndReferences::S3::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S3' in module 'SecondModule'}}
2873 // expected-note@second.h:* {{declaration of 'x' does not match}}
2880 #elif defined(SECOND)
2886 // expected-error@first.h:* {{PointersAndReferences::S4::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S4' in module 'SecondModule'}}
2887 // expected-note@second.h:* {{declaration of 'x' does not match}}
2894 #elif defined(SECOND)
2896 Wrapper
<const S5
*> x
;
2900 // expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 'SecondModule' is not present in definition of 'PointersAndReferences::S5' in module 'FirstModule'}}
2901 // expected-note@first.h:* {{declaration of 'x' does not match}}
2908 #elif defined(SECOND)
2910 Wrapper
<const int &> x
;
2914 // expected-error@first.h:* {{PointersAndReferences::S6::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S6' in module 'SecondModule'}}
2915 // expected-note@second.h:* {{declaration of 'x' does not match}}
2919 Wrapper<int *> x1; \
2920 Wrapper<float *> x2; \
2921 Wrapper<const float *> x3; \
2922 Wrapper<int &> x4; \
2923 Wrapper<int &&> x5; \
2924 Wrapper<const int &> x6; \
2929 #if defined(FIRST) || defined(SECOND)
2937 #if defined(FIRST) || defined(SECOND)
2944 // expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
2945 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
2948 } // namespace PointersAndReferences
2950 namespace FunctionTemplate
{
2953 template <int, int> void foo();
2955 #elif defined(SECOND)
2957 template <int> void foo();
2961 // expected-error@first.h:* {{'FunctionTemplate::S1::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S1' in module 'SecondModule'}}
2962 // expected-note@second.h:* {{declaration of 'foo' does not match}}
2967 template <char> void foo();
2969 #elif defined(SECOND)
2971 template <int> void foo();
2975 // expected-error@first.h:* {{'FunctionTemplate::S2::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S2' in module 'SecondModule'}}
2976 // expected-note@second.h:* {{declaration of 'foo' does not match}}
2981 template <int x
> void foo();
2983 #elif defined(SECOND)
2985 template <int y
> void foo();
2989 // 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'}}
2990 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}}
2995 template <int x
> void foo();
2997 #elif defined(SECOND)
2999 template <int x
> void bar();
3003 // expected-error@first.h:* {{'FunctionTemplate::S4::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S4' in module 'SecondModule'}}
3004 // expected-note@second.h:* {{definition has no member 'foo'}}
3009 template <int x
> void foo();
3011 #elif defined(SECOND)
3014 template <int x
> void foo();
3018 // expected-error@second.h:* {{'FunctionTemplate::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3019 // expected-note@first.h:* {{but in 'FirstModule' found function template}}
3024 template <typename x
= int> void foo();
3026 #elif defined(SECOND)
3028 template <typename x
> void foo();
3032 // 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}}
3033 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
3038 template <typename x
= void> void foo();
3040 #elif defined(SECOND)
3042 template <typename x
= int> void foo();
3046 // 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'}}
3047 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'void'}}
3054 template <template<int> class x
= U8
> void foo();
3056 #elif defined(SECOND)
3060 template <template<int> class x
= T8
> void foo();
3064 // 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'}}
3065 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'U8'}}
3072 template <template<int> class x
= U9
> void foo();
3074 #elif defined(SECOND)
3076 template <template<int> class x
> void foo();
3080 // 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}}
3081 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
3086 template <template<int> class x
> void foo();
3087 template <template<typename
> class x
> void foo();
3089 #elif defined(SECOND)
3091 template <template<typename
> class x
> void foo();
3092 template <template<int> class x
> void foo();
3096 // 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}}
3097 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}}
3102 template <template<int> class x
> void foo();
3104 #elif defined(SECOND)
3106 template <template<int> class> void foo();
3110 // 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}}
3111 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}}
3116 template <class> void foo();
3117 template <class, class> void foo();
3119 #elif defined(SECOND)
3121 template <class, class> void foo();
3122 template <class> void foo();
3126 // 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}}
3127 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1 template parameter}}
3132 template <class = int> void foo();
3134 #elif defined(SECOND)
3136 template <class = void> void foo();
3140 // 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'}}
3141 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'int'}}
3146 template <class = void> void foo();
3148 #elif defined(SECOND)
3150 template <class> void foo();
3154 // 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}}
3155 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}}
3160 template <class> void foo();
3162 #elif defined(SECOND)
3164 template <class = void> void foo();
3168 // 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}}
3169 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}}
3174 template <short> void foo();
3176 #elif defined(SECOND)
3178 template <short = 1> void foo();
3182 // 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}}
3183 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}}
3188 template <short = 2> void foo();
3190 #elif defined(SECOND)
3192 template <short = 1 + 1> void foo();
3196 // 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}}
3197 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 2}}
3202 template <short> void foo();
3203 template <int> void foo();
3205 #elif defined(SECOND)
3207 template <int> void foo();
3208 template <short> void foo();
3212 // 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}}
3213 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}}
3218 template <short> void foo();
3219 template <short...> void foo();
3221 #elif defined(SECOND)
3223 template <short...> void foo();
3224 template <short> void foo();
3228 // 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}}
3229 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}}
3234 template <class> void foo();
3235 template <class...> void foo();
3237 #elif defined(SECOND)
3239 template <class...> void foo();
3240 template <class> void foo();
3244 // 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}}
3245 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}}
3250 template <template<class> class...> void foo();
3251 template <template<class> class> void foo();
3253 #elif defined(SECOND)
3255 template <template<class> class> void foo();
3256 template <template<class> class...> void foo();
3260 // 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}}
3261 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter being a template parameter pack}}
3266 template <template<class> class> void foo();
3267 template <class> void foo();
3268 template <int> void foo();
3270 #elif defined(SECOND)
3272 template <class> void foo();
3273 template <int> void foo();
3274 template <template<class> class> void foo();
3278 // 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}}
3279 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a template template parameter}}
3284 template <class> void foo();
3285 template <int> void foo();
3286 template <template<class> class> void foo();
3288 #elif defined(SECOND)
3290 template <int> void foo();
3291 template <template<class> class> void foo();
3292 template <class> void foo();
3296 // 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}}
3297 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a type template parameter}}
3302 template <int> void foo();
3303 template <template<class> class> void foo();
3304 template <class> void foo();
3306 #elif defined(SECOND)
3308 template <template<class> class> void foo();
3309 template <class> void foo();
3310 template <int> void foo();
3314 // 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}}
3315 // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a non-type template parameter}}
3320 template <int> void foo();
3322 #elif defined(SECOND)
3325 template <int> void foo();
3329 // expected-error@second.h:* {{'FunctionTemplate::S25' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
3330 // expected-note@first.h:* {{but in 'FirstModule' found function template}}
3338 template <int, int> \
3340 template <int x = 5> \
3342 template <int... x> \
3347 template <class x> \
3349 template <class, class> \
3351 template <class x = int> \
3353 template <class... x> \
3356 template <template <int> class> \
3358 template <template <int> class x> \
3360 template <template <int> class, template <int> class> \
3362 template <template <int> class x = U> \
3364 template <template <int> class... x> \
3367 #if defined(FIRST) || defined(SECOND)
3377 #if defined(FIRST) || defined(SECOND)
3384 // expected-error@second.h:* {{'FunctionTemplate::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
3385 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
3393 #elif defined(SECOND)
3397 // expected-error@first.h:* {{'Enums::x11' from module 'FirstModule' is not present in definition of 'Enums::E1' in module 'SecondModule'}}
3398 // expected-note@second.h:* {{definition has no member 'x11'}}
3403 #elif defined(SECOND)
3407 // expected-error@second.h:* {{'Enums::E2' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 1 element}}
3408 // expected-note@first.h:* {{but in 'FirstModule' found enum with 0 elements}}
3413 #elif defined(SECOND)
3417 // expected-error@first.h:* {{'Enums::x31' from module 'FirstModule' is not present in definition of 'Enums::E3' in module 'SecondModule'}}
3418 // expected-note@second.h:* {{definition has no member 'x31'}}
3423 #elif defined(SECOND)
3424 enum E4
{ x41
, x42
};
3427 // expected-error@second.h:* {{'Enums::E4' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 2 elements}}
3428 // expected-note@first.h:* {{but in 'FirstModule' found enum with 1 element}}
3432 enum E5
{ x51
, x52
};
3433 #elif defined(SECOND)
3437 // expected-error@first.h:* {{'Enums::x52' from module 'FirstModule' is not present in definition of 'Enums::E5' in module 'SecondModule'}}
3438 // expected-note@second.h:* {{definition has no member 'x52'}}
3442 enum E6
{ x61
, x62
};
3443 #elif defined(SECOND)
3444 enum E6
{ x62
, x61
};
3447 // expected-error@second.h:* {{'Enums::E6' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element has name 'x62'}}
3448 // expected-note@first.h:* {{but in 'FirstModule' found 1st element has name 'x61'}}
3452 enum E7
{ x71
= 0 };
3453 #elif defined(SECOND)
3457 // 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}}
3458 // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x71' does not have an initializer}}
3463 #elif defined(SECOND)
3464 enum E8
{ x81
= 0 };
3467 // 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}}
3468 // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x81' has an initializer}}
3472 enum E9
{ x91
= 0, x92
= 1 };
3473 #elif defined(SECOND)
3474 enum E9
{ x91
= 0, x92
= 2 - 1 };
3477 // 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}}
3478 // expected-note@first.h:* {{but in 'FirstModule' found 2nd element 'x92' has different initializer}}
3482 enum class E10
: int {};
3483 #elif defined(SECOND)
3487 // expected-error@second.h:* {{'Enums::E10' has different definitions in different modules; definition in module 'SecondModule' first difference is enum without specified type}}
3488 // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type}}
3493 #elif defined(SECOND)
3497 // expected-error@second.h:* {{'Enums::E11' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type}}
3498 // expected-note@first.h:* {{but in 'FirstModule' found enum without specified type}}
3502 enum struct E12
: long {};
3503 #elif defined(SECOND)
3504 enum struct E12
: int {};
3507 // expected-error@second.h:* {{'Enums::E12' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type 'int'}}
3508 // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type 'long'}}
3513 #elif defined(SECOND)
3517 // expected-error@second.h:* {{'Enums::E13' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is not scoped}}
3518 // expected-note@first.h:* {{but in 'FirstModule' found enum that is scoped}}
3523 #elif defined(SECOND)
3527 // expected-error@second.h:* {{'Enums::E14' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is scoped}}
3528 // expected-note@first.h:* {{but in 'FirstModule' found enum that is not scoped}}
3533 #elif defined(SECOND)
3537 // expected-error@second.h:* {{'Enums::E15' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword struct}}
3538 // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword class}}
3543 #elif defined(SECOND)
3547 // expected-error@second.h:* {{'Enums::E16' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword class}}
3548 // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword struct}}
3552 enum Valid
{ v1
= (struct S
*)0 == (struct S
*)0 };
3553 #elif defined(SECOND)
3555 enum Valid
{ v1
= (struct S
*)0 == (struct S
*)0 };
3559 } // namespace Enums
3570 #elif defined(SECOND)
3578 auto function1
= invalid
;
3579 // expected-error@second.h:* {{'Types::Complex::invalid' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3580 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3581 auto function2
= valid
;
3583 } // namespace Complex
3585 namespace Decltype
{
3598 #elif defined(SECOND)
3611 auto function1
= invalid1
;
3612 // expected-error@second.h:* {{'Types::Decltype::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3613 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3614 auto function2
= invalid2
;
3615 // FIXME: We should reject the merge of `invalid2` and diagnose about the
3616 // inconsistent definition of `global`.
3617 auto function3
= valid
;
3619 } // namespace Decltype
3624 decltype(auto) x
= 1;
3633 decltype(auto) x
= 1;
3637 #elif defined(SECOND)
3645 decltype(auto) x
= 1;
3648 decltype(auto) x
= 1;
3653 auto function1
= invalid1
;
3654 // expected-error@second.h:* {{'Types::Auto::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3655 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3656 auto function2
= invalid3
;
3657 // expected-error@second.h:* {{'Types::Auto::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3658 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3659 auto function3
= invalid2
;
3660 // expected-error@second.h:* {{'Types::Auto::invalid3' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3661 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3662 auto function4
= valid
;
3666 namespace DeducedTemplateSpecialization
{
3668 template<typename T
> struct A
{};
3670 template<typename T
> struct B
{};
3682 #elif defined(SECOND)
3683 template<typename T
> struct A
{};
3685 template<typename T
> struct B
{};
3698 auto function1
= invalid1
;
3699 // FIXME: We should reject the merge of `invalid1` due to the inconsistent definition.
3700 auto function2
= invalid2
;
3701 // expected-error@second.h:* {{'Types::DeducedTemplateSpecialization::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3702 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3703 auto function3
= valid
;
3705 } // namespace DeducedTemplateSpecialization
3707 namespace DependentAddressSpace
{
3709 template <int A1
, int A2
>
3711 using type
= int __attribute__((address_space(A1
)));
3715 using type
= float __attribute__((address_space(A1
)));
3717 template <int A1
, int A2
>
3719 using type1
= float __attribute__((address_space(A1
)));
3720 using type2
= int __attribute__((address_space(A2
)));
3721 using type3
= int __attribute__((address_space(A1
+ A2
)));
3723 #elif defined(SECOND)
3724 template <int A1
, int A2
>
3726 using type
= int __attribute__((address_space(A2
)));
3730 using type
= int __attribute__((address_space(A1
)));
3732 template <int A1
, int A2
>
3734 using type1
= float __attribute__((address_space(A1
)));
3735 using type2
= int __attribute__((address_space(A2
)));
3736 using type3
= int __attribute__((address_space(A1
+ A2
)));
3739 template <int A
, int B
>
3741 static auto function1
= invalid1
<A
, B
>;
3742 // expected-error@first.h:* {{'Types::DependentAddressSpace::invalid1' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3743 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3744 static auto function2
= invalid2
<B
>;
3745 // expected-error@first.h:* {{'Types::DependentAddressSpace::invalid2' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3746 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3747 static auto function3
= valid
<A
, B
>;
3750 } // namespace DependentAddressSpace
3752 namespace DependentSizedExtVector
{
3756 typedef int __attribute__((ext_vector_type(Size
))) type
;
3760 typedef int __attribute__((ext_vector_type(Size
+ 0))) type
;
3764 typedef int __attribute__((ext_vector_type(Size
))) type
;
3766 #elif defined(SECOND)
3769 typedef float __attribute__((ext_vector_type(Size
))) type
;
3773 typedef int __attribute__((ext_vector_type(Size
+ 1))) type
;
3777 typedef int __attribute__((ext_vector_type(Size
))) type
;
3782 static auto Function1
= invalid1
<Num
>;
3783 // expected-error@first.h:* {{'Types::DependentSizedExtVector::invalid1' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3784 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3785 static auto Function2
= invalid2
<Num
>;
3786 // expected-error@first.h:* {{'Types::DependentSizedExtVector::invalid2' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}}
3787 // expected-note@second.h:* {{but in 'SecondModule' found a different body}}
3788 static auto Function3
= valid
<Num
>;
3791 } // namespace DependentSizedExtVector
3793 namespace InjectedClassName
{
3814 #elif defined(SECOND)
3835 Invalid::L2
<1>::L3
<1> invalid
;
3836 // expected-error@second.h:* {{'Types::InjectedClassName::Invalid::L2::L3::x' from module 'SecondModule' is not present in definition of 'L3<>' in module 'FirstModule'}}
3837 // expected-note@first.h:* {{declaration of 'x' does not match}}
3838 Valid::L2
<1>::L3
<1> valid
;
3840 } // namespace InjectedClassName
3842 namespace MemberPointer
{
3862 void (B::*fun3
)(int);
3863 void (B::*fun4
)(bool*, int);
3865 #elif defined(SECOND)
3876 int (A::*x
)(int, int);
3884 void (B::*fun3
)(int);
3885 void (B::*fun4
)(bool*, int);
3888 auto function1
= Invalid1
;
3889 // expected-error@second.h:* {{'Types::MemberPointer::Invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3890 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3891 auto function2
= Invalid2
;
3892 // expected-error@second.h:* {{'Types::MemberPointer::Invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3893 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3894 auto function3
= Invalid3
;
3895 // expected-error@second.h:* {{'Types::MemberPointer::Invalid3' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3896 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3897 auto function4
= Valid
;
3900 } // namespace MemberPointer
3902 namespace PackExpansion
{
3905 template <class... A
>
3907 template <class... B
>
3915 template <class... A
>
3917 template <class... B
>
3924 #elif defined(SECOND)
3926 template <class... A
>
3928 template <class... B
>
3936 template <class... A
>
3938 template <class... B
>
3946 Invalid::L2
<int>::L3
<short, bool> invalid
;
3947 // 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...'}}
3948 // expected-note@second.h:* {{but in 'SecondModule' found method 'run' with 1st parameter of type 'B...'}}
3949 Valid::L2
<int>::L3
<short, bool> valid
;
3952 } // namespace PackExpansion
3962 #elif defined(SECOND)
3970 auto function1
= invalid
;
3971 // expected-error@second.h:* {{'Types::Paren::invalid' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
3972 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
3973 auto function2
= valid
;
3975 } // namespace Paren
3977 namespace SubstTemplateTypeParm
{
3979 template <class> struct wrapper
{};
3980 template <class, class, class> struct triple
{};
3983 template <class _T
, class _U
, class = wrapper
<_T
>> class A
= triple
>
3988 #elif defined(SECOND)
3989 template <class> struct wrapper
{};
3990 template <class, class, class> struct triple
{};
3993 template <class _T
, class _U
, class = wrapper
<_T
>> class A
= triple
>
4000 template <class _T
, class _U
, class = wrapper
<_T
>> class A
= triple
>
4001 using V
= Valid::L2
<T
, A
>;
4003 } // namespace SubstTemplateTypeParm
4005 namespace SubstTemplateTypeParmPack
{
4006 } // namespace SubstTemplateTypeParmPack
4008 namespace UnaryTransform
{
4010 enum class E1a
: unsigned {};
4012 __underlying_type(E1a
) x
;
4014 enum E2a
: unsigned {};
4016 __underlying_type(E2a
) x
;
4020 __underlying_type(E3a
) x
;
4024 __underlying_type(E4a
) x
;
4028 __underlying_type(E1
) x
;
4030 enum E2
: unsigned {};
4032 __underlying_type(E2
) x
;
4036 __underlying_type(E3
) x
;
4038 #elif defined(SECOND)
4039 enum class E1b
: signed {};
4041 __underlying_type(E1b
) x
;
4043 enum class E2b
: unsigned {};
4045 __underlying_type(E2b
) x
;
4049 __underlying_type(E3b
) x
;
4053 __underlying_type(E4b
) x
;
4057 // expected-error@first.h:* {{'Types::UnaryTransform::Invalid1::x' from module 'FirstModule' is not present in definition of 'Types::UnaryTransform::Invalid1' in module 'SecondModule'}}
4058 // expected-note@second.h:* {{declaration of 'x' does not match}}
4060 // 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')}}
4061 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type '__underlying_type(E2a)' (aka 'unsigned int')}}
4063 // expected-error@first.h:* {{'Types::UnaryTransform::Invalid3::x' from module 'FirstModule' is not present in definition of 'Types::UnaryTransform::Invalid3' in module 'SecondModule'}}
4064 // expected-note@second.h:* {{declaration of 'x' does not match}}
4066 // 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')}}
4067 // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type '__underlying_type(E4a)' (aka 'unsigned int')}}
4072 } // namespace UnaryTransform
4074 namespace UnresolvedUsing
{
4076 template <class T
> struct wrapper
{};
4079 using typename wrapper
<T
>::T1
;
4080 using typename wrapper
<T
>::T2
;
4085 using typename wrapper
<T
>::T1
;
4086 using typename wrapper
<T
>::T2
;
4090 #elif defined(SECOND)
4091 template <class T
> struct wrapper
{};
4094 using typename wrapper
<T
>::T1
;
4095 using typename wrapper
<T
>::T2
;
4100 using typename wrapper
<T
>::T1
;
4101 using typename wrapper
<T
>::T2
;
4106 template <class T
> using I
= Invalid
<T
>;
4107 // expected-error@first.h:* {{'Types::UnresolvedUsing::Invalid::x' from module 'FirstModule' is not present in definition of 'Invalid<T>' in module 'SecondModule'}}
4108 // expected-note@second.h:* {{declaration of 'x' does not match}}
4110 template <class T
> using V
= Valid
<T
>;
4113 } // namespace UnresolvedUsing
4116 // void invalid1() {
4117 // __attribute((vector_size(8))) int *x1;
4120 } // namespace Types
4122 // Collection of interesting cases below.
4124 // Naive parsing of AST can lead to cycles in processing. Ensure
4125 // self-references don't trigger an endless cycles of AST node processing.
4126 namespace SelfReference
{
4128 template <template <int> class T
> class Wrapper
{};
4130 template <int N
> class S
{
4131 S(Wrapper
<::SelfReference::S
> &Ref
) {}
4142 template <typename
> struct Foo
;
4143 template <template <class> class T
= NNS::Foo
>
4144 struct NestedNamespaceSpecifier
{};
4147 } // namespace SelfReference
4149 namespace FriendFunction
{
4152 struct S
{ friend void F(int); };
4153 #elif defined(SECOND)
4155 struct S
{ friend void F(int); };
4167 #elif defined(SECOND)
4176 // expected-error@second.h:* {{'FriendFunction::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
4177 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
4179 } // namespace FriendFunction
4181 namespace ImplicitDecl
{
4184 void S_Constructors() {
4185 // Trigger creation of implicit contructors
4190 #elif defined(SECOND)
4200 void T_Constructors() {
4201 // Trigger creation of implicit contructors
4206 #elif defined(SECOND)
4212 // expected-error@first.h:* {{'ImplicitDecl::T' has different definitions in different modules; first difference is definition in module 'FirstModule' found private access specifier}}
4213 // expected-note@second.h:* {{but in 'SecondModule' found public access specifier}}
4216 } // namespace ImplicitDecl
4218 namespace TemplatedClass
{
4222 #elif defined(SECOND)
4234 #elif defined(SECOND)
4241 // expected-error@second.h:* {{'TemplatedClass::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
4242 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
4244 } // namespace TemplatedClass
4246 namespace TemplateClassWithField
{
4252 #elif defined(SECOND)
4268 #elif defined(SECOND)
4277 // expected-error@second.h:* {{'TemplateClassWithField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}}
4278 // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}}
4280 } // namespace TemplateClassWithField
4282 namespace TemplateClassWithTemplateField
{
4290 #elif defined(SECOND)
4312 #elif defined(SECOND)
4325 // expected-error@second.h:* {{'TemplateClassWithTemplateField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4326 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4328 } // namespace TemplateClassWithTemplateField
4330 namespace EnumWithForwardDeclaration
{
4336 #elif defined(SECOND)
4337 enum E
: int { A
, B
};
4350 #elif defined(SECOND)
4357 // expected-error@second.h:* {{'EnumWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4358 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4360 } // namespace EnumWithForwardDeclaration
4362 namespace StructWithForwardDeclaration
{
4368 #elif defined(SECOND)
4382 #elif defined(SECOND)
4389 // expected-error@second.h:* {{'StructWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4390 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4392 } // namespace StructWithForwardDeclaration
4394 namespace StructWithForwardDeclarationNoDefinition
{
4400 #elif defined(SECOND)
4415 #elif defined(SECOND)
4423 // expected-error@second.h:* {{'StructWithForwardDeclarationNoDefinition::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
4424 // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
4426 } // namespace StructWithForwardDeclarationNoDefinition
4428 namespace LateParsedDefaultArgument
{
4430 template <typename T
>
4433 void foo(T x
= 0) {}
4436 #elif defined(SECOND)
4442 } // namespace LateParsedDefaultArgument
4444 namespace LateParsedDefaultArgument
{
4446 template <typename alpha
> struct Bravo
{
4447 void charlie(bool delta
= false) {}
4449 typedef Bravo
<char> echo
;
4453 #elif defined(SECOND)
4456 } // LateParsedDefaultArgument
4458 namespace DifferentParameterNameInTemplate
{
4459 #if defined(FIRST) || defined(SECOND)
4460 template <typename T
>
4464 static void Run(const Type
*name_one
);
4467 template <typename T
>
4468 void S
<T
>::Run(const T
*name_two
) {}
4470 template <typename T
>
4472 ~Foo() { Handler::Run(nullptr); }
4475 class Handler
: public S
<T
> {};
4477 void Get(typename
Handler::Type
*x
= nullptr) {}
4478 void Add() { Handler::Run(nullptr); }
4487 void Go() { betas
.Get(); }
4491 #elif defined(SECOND)
4495 void add_Beta() { betas
.Add(); }
4502 } // DifferentParameterNameInTemplate
4504 namespace ParameterTest
{
4507 template <typename G
>
4511 static inline G
*Foo(const G
*a
, int * = nullptr);
4514 template<typename G
>
4515 G
* S
<G
>::Foo(const G
* aaaa
, int*) {}
4516 #elif defined(SECOND)
4517 template <typename G
>
4521 static inline G
*Foo(const G
*a
, int * = nullptr);
4524 template<typename G
>
4525 G
* S
<G
>::Foo(const G
* asdf
, int*) {}
4528 // 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'}}
4529 // expected-note@second.h:* {{but in 'SecondModule' found 1st parameter with name 'asdf'}}
4533 namespace MultipleTypedefs
{
4540 #elif defined(SECOND)
4550 struct T2
{ int x
; };
4556 #elif defined(SECOND)
4557 struct T2
{ int x
; };
4567 using A3
= const int;
4568 using B3
= volatile A3
;
4572 #elif defined(SECOND)
4573 using A3
= volatile const int;
4588 #elif defined(SECOND)
4590 using B4
= ::MultipleTypedefs::A4
;
4600 using B5
= MultipleTypedefs::A5
;
4604 #elif defined(SECOND)
4606 using B5
= ::MultipleTypedefs::A5
;
4613 } // MultipleTypedefs
4615 namespace DefaultArguments
{
4617 template <typename T
>
4623 #elif defined(SECOND)
4624 template <typename T
>
4634 // 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}}
4635 // expected-note@first.h:* {{but in 'FirstModule' found method 'foo' with 1st parameter with a different default argument}}
4639 template <typename alpha
> struct Bravo
{
4640 void charlie(bool delta
= false);
4642 typedef Bravo
<char> echo
;
4644 #elif defined(SECOND)
4645 template <typename alpha
> struct Bravo
{
4646 void charlie(bool delta
= (false));
4648 typedef Bravo
<char> echo
;
4652 // 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}}
4653 // expected-note@first.h:* {{but in 'FirstModule' found method 'charlie' with 1st parameter with a different default argument}}
4655 } // namespace DefaultArguments
4657 namespace FunctionDecl
{
4661 #elif defined(SECOND)
4672 #elif defined(SECOND)
4685 #elif defined(SECOND)
4693 #if defined(FIRST) || defined(SECOND)
4694 int F1(int x
, float y
= 2.7) { return 1; }
4700 int F2() { return 1; }
4701 #elif defined(SECOND)
4702 double F2() { return 1; }
4705 // expected-error@-1 {{call to 'F2' is ambiguous}}
4706 // expected-note@first.h:* {{candidate function}}
4707 // expected-note@second.h:* {{candidate function}}
4711 int F3(float) { return 1; }
4712 #elif defined(SECOND)
4713 int F3(double) { return 1; }
4716 // expected-error@-1 {{call to 'F3' is ambiguous}}
4717 // expected-note@first.h:* {{candidate function}}
4718 // expected-note@second.h:* {{candidate function}}
4722 int F4(int x
) { return 1; }
4723 #elif defined(SECOND)
4724 int F4(int y
) { return 1; }
4727 // expected-error@second.h:* {{'FunctionDecl::F4' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with name 'y'}}
4728 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with name 'x'}}
4732 int F5(int x
) { return 1; }
4733 #elif defined(SECOND)
4734 int F5(int x
= 1) { return 1; }
4737 // 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}}
4738 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a default argument}}
4742 int F6(int x
= 2) { return 1; }
4743 #elif defined(SECOND)
4744 int F6(int x
= 1) { return 1; }
4747 // 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}}
4748 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a different default argument}}
4753 I
F7() { return 0; }
4754 #elif defined(SECOND)
4755 int F7() { return 0; }
4758 // expected-error@second.h:* {{'FunctionDecl::F7' has different definitions in different modules; definition in module 'SecondModule' first difference is return type is 'int'}}
4759 // expected-note@first.h:* {{but in 'FirstModule' found different return type 'I' (aka 'int')}}
4763 int F8(int) { return 0; }
4764 #elif defined(SECOND)
4765 int F8(I
) { return 0; }
4768 // 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')}}
4769 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int'}}
4773 int F9(int[1]) { return 0; }
4774 #elif defined(SECOND)
4775 int F9(int[2]) { return 0; }
4777 int I9
= F9(nullptr);
4778 // 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]'}}
4779 // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int *' decayed from 'int[1]'}}
4783 int F10() { return 1; }
4784 #elif defined(SECOND)
4785 int F10() { return 2; }
4789 // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4790 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4794 template <int> void foo();
4796 #elif defined(SECOND)
4798 template <int> void foo();
4800 template <int> void S11::foo() {}
4809 #elif defined(SECOND)
4813 void S12::foo(int y
) {}
4822 void S13::foo(int y
) {}
4823 #elif defined(SECOND)
4827 void S13::foo(int y
) {}
4831 } // namespace FunctionDecl
4833 namespace DeclTemplateArguments
{
4835 int foo() { return 1; }
4836 int bar() { return foo(); }
4837 #elif defined(SECOND)
4838 template <class T
= int>
4839 int foo() { return 2; }
4840 int bar() { return foo
<>(); }
4843 // expected-error@second.h:* {{'DeclTemplateArguments::bar' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}
4844 // expected-note@first.h:* {{but in 'FirstModule' found a different body}}
4848 namespace FunctionProtoTypeDecay
{
4854 #elif defined(SECOND)
4857 using Y
= X(X(X()));
4861 // expected-error@first.h:* {{'FunctionProtoTypeDecay::S1::Y' from module 'FirstModule' is not present in definition of 'FunctionProtoTypeDecay::S1' in module 'SecondModule'}}
4862 // expected-note@second.h:* {{declaration of 'Y' does not match}}
4869 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
4870 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
4871 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
4872 X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(X(
4878 #elif defined(SECOND)
4884 namespace TypedefStruct
{
4890 #elif defined(SECOND)
4891 typedef struct T1
{} T1
;
4902 const T2
* t
= nullptr;
4904 #elif defined(SECOND)
4905 typedef struct T2
{} T2
;
4907 const T2
* t
= nullptr;
4916 T3
* const t
= nullptr;
4918 #elif defined(SECOND)
4919 typedef struct T3
{} T3
;
4921 T3
* const t
= nullptr;
4934 #elif defined(SECOND)
4936 typedef struct T4
{} T4
;
4952 #elif defined(SECOND)
4954 typedef struct T5_Other
{} T5
;
4961 // expected-error@first.h:* {{'TypedefStruct::S5::t' from module 'FirstModule' is not present in definition of 'TypedefStruct::S5' in module 'SecondModule'}}
4962 // expected-note@second.h:* {{declaration of 't' does not match}}
4964 } // namespace TypedefStruct
4971 #elif defined(SECOND)
4980 // Keep macros contained to one file.