1 | // Clear and create directories |
2 | // RUN: rm -rf %t |
3 | // RUN: mkdir %t |
4 | // RUN: mkdir %t/cache |
5 | // RUN: mkdir %t/Inputs |
6 | |
7 | // Build first header file |
8 | // RUN: echo "#define FIRST" >> %t/Inputs/first.h |
9 | // RUN: cat %s >> %t/Inputs/first.h |
10 | |
11 | // Build second header file |
12 | // RUN: echo "#define SECOND" >> %t/Inputs/second.h |
13 | // RUN: cat %s >> %t/Inputs/second.h |
14 | |
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 |
18 | |
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 |
26 | |
27 | // Run test |
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 |
31 | |
32 | #if !defined(FIRST) && !defined(SECOND) |
33 | #include "first.h" |
34 | #include "second.h" |
35 | #endif |
36 | |
37 | // Used for testing |
38 | #if defined(FIRST) |
39 | #define ACCESS public: |
40 | #elif defined(SECOND) |
41 | #define ACCESS private: |
42 | #endif |
43 | |
44 | namespace AccessSpecifiers { |
45 | #if defined(FIRST) |
46 | struct S1 { |
47 | }; |
48 | #elif defined(SECOND) |
49 | struct S1 { |
50 | private: |
51 | }; |
52 | #else |
53 | S1 s1; |
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}} |
56 | #endif |
57 | |
58 | #if defined(FIRST) |
59 | struct S2 { |
60 | public: |
61 | }; |
62 | #elif defined(SECOND) |
63 | struct S2 { |
64 | protected: |
65 | }; |
66 | #else |
67 | S2 s2; |
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}} |
70 | #endif |
71 | |
72 | #define DECLS \ |
73 | public: \ |
74 | private: \ |
75 | protected: |
76 | |
77 | #if defined(FIRST) || defined(SECOND) |
78 | struct Valid1 { |
79 | DECLS |
80 | }; |
81 | #else |
82 | Valid1 v1; |
83 | #endif |
84 | |
85 | #if defined(FIRST) || defined(SECOND) |
86 | struct Invalid1 { |
87 | DECLS |
88 | ACCESS |
89 | }; |
90 | #else |
91 | Invalid1 i1; |
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}} |
94 | #endif |
95 | |
96 | #undef DECLS |
97 | } // namespace AccessSpecifiers |
98 | |
99 | namespace StaticAssert { |
100 | #if defined(FIRST) |
101 | struct S1 { |
102 | static_assert(1 == 1, "First"); |
103 | }; |
104 | #elif defined(SECOND) |
105 | struct S1 { |
106 | static_assert(1 == 1, "Second"); |
107 | }; |
108 | #else |
109 | S1 s1; |
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}} |
112 | #endif |
113 | |
114 | #if defined(FIRST) |
115 | struct S2 { |
116 | static_assert(2 == 2, "Message"); |
117 | }; |
118 | #elif defined(SECOND) |
119 | struct S2 { |
120 | static_assert(2 == 2); |
121 | }; |
122 | #else |
123 | S2 s2; |
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}} |
126 | #endif |
127 | |
128 | #if defined(FIRST) |
129 | struct S3 { |
130 | static_assert(3 == 3, "Message"); |
131 | }; |
132 | #elif defined(SECOND) |
133 | struct S3 { |
134 | static_assert(3 != 4, "Message"); |
135 | }; |
136 | #else |
137 | S3 s3; |
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}} |
140 | #endif |
141 | |
142 | #if defined(FIRST) |
143 | struct S4 { |
144 | static_assert(4 == 4, "Message"); |
145 | }; |
146 | #elif defined(SECOND) |
147 | struct S4 { |
148 | public: |
149 | }; |
150 | #else |
151 | S4 s4; |
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}} |
154 | #endif |
155 | |
156 | #define DECLS \ |
157 | static_assert(4 == 4, "Message"); \ |
158 | static_assert(5 == 5); |
159 | |
160 | #if defined(FIRST) || defined(SECOND) |
161 | struct Valid1 { |
162 | DECLS |
163 | }; |
164 | #else |
165 | Valid1 v1; |
166 | #endif |
167 | |
168 | #if defined(FIRST) || defined(SECOND) |
169 | struct Invalid1 { |
170 | DECLS |
171 | ACCESS |
172 | }; |
173 | #else |
174 | Invalid1 i1; |
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}} |
177 | #endif |
178 | #undef DECLS |
179 | } // namespace StaticAssert |
180 | |
181 | namespace Field { |
182 | #if defined(FIRST) |
183 | struct S1 { |
184 | int x; |
185 | private: |
186 | int y; |
187 | }; |
188 | #elif defined(SECOND) |
189 | struct S1 { |
190 | int x; |
191 | int y; |
192 | }; |
193 | #else |
194 | S1 s1; |
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}} |
197 | #endif |
198 | |
199 | #if defined(FIRST) |
200 | struct S2 { |
201 | int x; |
202 | int y; |
203 | }; |
204 | #elif defined(SECOND) |
205 | struct S2 { |
206 | int y; |
207 | int x; |
208 | }; |
209 | #else |
210 | S2 s2; |
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'}} |
213 | #endif |
214 | |
215 | #if defined(FIRST) |
216 | struct S3 { |
217 | double x; |
218 | }; |
219 | #elif defined(SECOND) |
220 | struct S3 { |
221 | int x; |
222 | }; |
223 | #else |
224 | S3 s3; |
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}} |
227 | #endif |
228 | |
229 | #if defined(FIRST) |
230 | typedef int A; |
231 | struct S4 { |
232 | A x; |
233 | }; |
234 | |
235 | struct S5 { |
236 | A x; |
237 | }; |
238 | #elif defined(SECOND) |
239 | typedef int B; |
240 | struct S4 { |
241 | B x; |
242 | }; |
243 | |
244 | struct S5 { |
245 | int x; |
246 | }; |
247 | #else |
248 | S4 s4; |
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 'Field::B' (aka 'int')}} |
250 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'Field::A' (aka 'int')}} |
251 | |
252 | S5 s5; |
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 'Field::A' (aka 'int')}} |
255 | #endif |
256 | |
257 | #if defined(FIRST) |
258 | struct S6 { |
259 | unsigned x; |
260 | }; |
261 | #elif defined(SECOND) |
262 | struct S6 { |
263 | unsigned x : 1; |
264 | }; |
265 | #else |
266 | S6 s6; |
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'}} |
269 | #endif |
270 | |
271 | #if defined(FIRST) |
272 | struct S7 { |
273 | unsigned x : 2; |
274 | }; |
275 | #elif defined(SECOND) |
276 | struct S7 { |
277 | unsigned x : 1; |
278 | }; |
279 | #else |
280 | S7 s7; |
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}} |
283 | #endif |
284 | |
285 | #if defined(FIRST) |
286 | struct S8 { |
287 | unsigned x : 2; |
288 | }; |
289 | #elif defined(SECOND) |
290 | struct S8 { |
291 | unsigned x : 1 + 1; |
292 | }; |
293 | #else |
294 | S8 s8; |
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}} |
297 | #endif |
298 | |
299 | #if defined(FIRST) |
300 | struct S9 { |
301 | mutable int x; |
302 | }; |
303 | #elif defined(SECOND) |
304 | struct S9 { |
305 | int x; |
306 | }; |
307 | #else |
308 | S9 s9; |
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'}} |
311 | #endif |
312 | |
313 | #if defined(FIRST) |
314 | struct S10 { |
315 | unsigned x = 5; |
316 | }; |
317 | #elif defined(SECOND) |
318 | struct S10 { |
319 | unsigned x; |
320 | }; |
321 | #else |
322 | S10 s10; |
323 | // expected-error@second.h:* {{'Field::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with no initalizer}} |
324 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with an initializer}} |
325 | #endif |
326 | |
327 | #if defined(FIRST) |
328 | struct S11 { |
329 | unsigned x = 5; |
330 | }; |
331 | #elif defined(SECOND) |
332 | struct S11 { |
333 | unsigned x = 7; |
334 | }; |
335 | #else |
336 | S11 s11; |
337 | // 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}} |
338 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}} |
339 | #endif |
340 | |
341 | #if defined(FIRST) |
342 | struct S12 { |
343 | unsigned x[5]; |
344 | }; |
345 | #elif defined(SECOND) |
346 | struct S12 { |
347 | unsigned x[7]; |
348 | }; |
349 | #else |
350 | S12 s12; |
351 | // expected-error@first.h:* {{'Field::S12::x' from module 'FirstModule' is not present in definition of 'Field::S12' in module 'SecondModule'}} |
352 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
353 | #endif |
354 | |
355 | #if defined(FIRST) |
356 | struct S13 { |
357 | unsigned x[7]; |
358 | }; |
359 | #elif defined(SECOND) |
360 | struct S13 { |
361 | double x[7]; |
362 | }; |
363 | #else |
364 | S13 s13; |
365 | // expected-error@first.h:* {{'Field::S13::x' from module 'FirstModule' is not present in definition of 'Field::S13' in module 'SecondModule'}} |
366 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
367 | #endif |
368 | |
369 | #define DECLS \ |
370 | int a; \ |
371 | int b : 3; \ |
372 | unsigned c : 1 + 2; \ |
373 | s d; \ |
374 | double e = 1.0; \ |
375 | long f[5]; |
376 | |
377 | #if defined(FIRST) || defined(SECOND) |
378 | typedef short s; |
379 | #endif |
380 | |
381 | #if defined(FIRST) || defined(SECOND) |
382 | struct Valid1 { |
383 | DECLS |
384 | }; |
385 | #else |
386 | Valid1 v1; |
387 | #endif |
388 | |
389 | #if defined(FIRST) || defined(SECOND) |
390 | struct Invalid1 { |
391 | DECLS |
392 | ACCESS |
393 | }; |
394 | #else |
395 | Invalid1 i1; |
396 | // expected-error@second.h:* {{'Field::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
397 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
398 | #endif |
399 | #undef DECLS |
400 | } // namespace Field |
401 | |
402 | namespace Method { |
403 | #if defined(FIRST) |
404 | struct S1 { |
405 | void A() {} |
406 | }; |
407 | #elif defined(SECOND) |
408 | struct S1 { |
409 | private: |
410 | void A() {} |
411 | }; |
412 | #else |
413 | S1 s1; |
414 | // expected-error@second.h:* {{'Method::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
415 | // expected-note@first.h:* {{but in 'FirstModule' found method}} |
416 | #endif |
417 | |
418 | #if defined(FIRST) |
419 | struct S2 { |
420 | void A() {} |
421 | void B() {} |
422 | }; |
423 | #elif defined(SECOND) |
424 | struct S2 { |
425 | void B() {} |
426 | void A() {} |
427 | }; |
428 | #else |
429 | S2 s2; |
430 | // expected-error@second.h:* {{'Method::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'B'}} |
431 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A'}} |
432 | #endif |
433 | |
434 | #if defined(FIRST) |
435 | struct S3 { |
436 | static void A() {} |
437 | void A(int) {} |
438 | }; |
439 | #elif defined(SECOND) |
440 | struct S3 { |
441 | void A(int) {} |
442 | static void A() {} |
443 | }; |
444 | #else |
445 | S3 s3; |
446 | // 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}} |
447 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is static}} |
448 | #endif |
449 | |
450 | #if defined(FIRST) |
451 | struct S4 { |
452 | virtual void A() {} |
453 | void B() {} |
454 | }; |
455 | #elif defined(SECOND) |
456 | struct S4 { |
457 | void A() {} |
458 | virtual void B() {} |
459 | }; |
460 | #else |
461 | S4 s4; |
462 | // 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}} |
463 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is virtual}} |
464 | #endif |
465 | |
466 | #if defined(FIRST) |
467 | struct S5 { |
468 | virtual void A() = 0; |
469 | virtual void B() {}; |
470 | }; |
471 | #elif defined(SECOND) |
472 | struct S5 { |
473 | virtual void A() {} |
474 | virtual void B() = 0; |
475 | }; |
476 | #else |
477 | S5 *s5; |
478 | // expected-error@second.h:* {{'Method::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is virtual}} |
479 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is pure virtual}} |
480 | #endif |
481 | |
482 | #if defined(FIRST) |
483 | struct S6 { |
484 | inline void A() {} |
485 | }; |
486 | #elif defined(SECOND) |
487 | struct S6 { |
488 | void A() {} |
489 | }; |
490 | #else |
491 | S6 s6; |
492 | // 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}} |
493 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is inline}} |
494 | #endif |
495 | |
496 | #if defined(FIRST) |
497 | struct S7 { |
498 | void A() volatile {} |
499 | void A() {} |
500 | }; |
501 | #elif defined(SECOND) |
502 | struct S7 { |
503 | void A() {} |
504 | void A() volatile {} |
505 | }; |
506 | #else |
507 | S7 s7; |
508 | // 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}} |
509 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is volatile}} |
510 | #endif |
511 | |
512 | #if defined(FIRST) |
513 | struct S8 { |
514 | void A() const {} |
515 | void A() {} |
516 | }; |
517 | #elif defined(SECOND) |
518 | struct S8 { |
519 | void A() {} |
520 | void A() const {} |
521 | }; |
522 | #else |
523 | S8 s8; |
524 | // 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}} |
525 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is const}} |
526 | #endif |
527 | |
528 | #if defined(FIRST) |
529 | struct S9 { |
530 | void A(int x) {} |
531 | void A(int x, int y) {} |
532 | }; |
533 | #elif defined(SECOND) |
534 | struct S9 { |
535 | void A(int x, int y) {} |
536 | void A(int x) {} |
537 | }; |
538 | #else |
539 | S9 s9; |
540 | // 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}} |
541 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' that has 1 parameter}} |
542 | #endif |
543 | |
544 | #if defined(FIRST) |
545 | struct S10 { |
546 | void A(int x) {} |
547 | void A(float x) {} |
548 | }; |
549 | #elif defined(SECOND) |
550 | struct S10 { |
551 | void A(float x) {} |
552 | void A(int x) {} |
553 | }; |
554 | #else |
555 | S10 s10; |
556 | // 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'}} |
557 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int'}} |
558 | #endif |
559 | |
560 | #if defined(FIRST) |
561 | struct S11 { |
562 | void A(int x); |
563 | }; |
564 | #elif defined(SECOND) |
565 | struct S11 { |
566 | void A(int y); |
567 | }; |
568 | #else |
569 | S11 s11; |
570 | // 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'}} |
571 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter named 'x'}} |
572 | #endif |
573 | |
574 | #if defined(FIRST) |
575 | struct S12 { |
576 | void A(int x); |
577 | }; |
578 | #elif defined(SECOND) |
579 | struct S12 { |
580 | void A(int x = 1); |
581 | }; |
582 | #else |
583 | S12 s12; |
584 | // 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}} |
585 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a default argument}} |
586 | #endif |
587 | |
588 | #if defined(FIRST) |
589 | struct S13 { |
590 | void A(int x = 1 + 0); |
591 | }; |
592 | #elif defined(SECOND) |
593 | struct S13 { |
594 | void A(int x = 1); |
595 | }; |
596 | #else |
597 | S13 s13; |
598 | // 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}} |
599 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a different default argument}} |
600 | #endif |
601 | |
602 | #if defined(FIRST) |
603 | struct S14 { |
604 | void A(int x[2]); |
605 | }; |
606 | #elif defined(SECOND) |
607 | struct S14 { |
608 | void A(int x[3]); |
609 | }; |
610 | #else |
611 | S14 s14; |
612 | // 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]'}} |
613 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [2]'}} |
614 | #endif |
615 | |
616 | #if defined(FIRST) |
617 | struct S15 { |
618 | int A() { return 0; } |
619 | }; |
620 | #elif defined(SECOND) |
621 | struct S15 { |
622 | long A() { return 0; } |
623 | }; |
624 | #else |
625 | S15 s15; |
626 | // expected-error@first.h:* {{'Method::S15::A' from module 'FirstModule' is not present in definition of 'Method::S15' in module 'SecondModule'}} |
627 | // expected-note@second.h:* {{declaration of 'A' does not match}} |
628 | #endif |
629 | |
630 | #define DECLS \ |
631 | void A(); \ |
632 | static void B(); \ |
633 | virtual void C(); \ |
634 | virtual void D() = 0; \ |
635 | inline void E(); \ |
636 | void F() const; \ |
637 | void G() volatile; \ |
638 | void H(int x); \ |
639 | void I(int x = 5 + 5); \ |
640 | void J(int); \ |
641 | void K(int x[2]); \ |
642 | int L(); |
643 | |
644 | #if defined(FIRST) || defined(SECOND) |
645 | struct Valid1 { |
646 | DECLS |
647 | }; |
648 | #else |
649 | Valid1* v1; |
650 | #endif |
651 | |
652 | #if defined(FIRST) || defined(SECOND) |
653 | struct Invalid1 { |
654 | DECLS |
655 | ACCESS |
656 | }; |
657 | #else |
658 | Invalid1* i1; |
659 | // expected-error@second.h:* {{'Method::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
660 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
661 | #endif |
662 | #undef DECLS |
663 | } // namespace Method |
664 | |
665 | namespace MethodBody { |
666 | #if defined(FIRST) |
667 | struct S1 { |
668 | int A() { return 0; } |
669 | }; |
670 | #elif defined(SECOND) |
671 | struct S1 { |
672 | int A() { return 0; } |
673 | }; |
674 | #else |
675 | S1 s1; |
676 | #endif |
677 | |
678 | #if defined(FIRST) |
679 | struct S2 { |
680 | int BothBodies() { return 0; } |
681 | }; |
682 | #elif defined(SECOND) |
683 | struct S2 { |
684 | int BothBodies() { return 1; } |
685 | }; |
686 | #else |
687 | S2 s2; |
688 | // expected-error@first.h:* {{'MethodBody::S2' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'BothBodies' with body}} |
689 | // expected-note@second.h:* {{but in 'SecondModule' found method 'BothBodies' with different body}} |
690 | #endif |
691 | |
692 | #if defined(FIRST) |
693 | struct S3 { |
694 | int FirstBody() { return 0; } |
695 | }; |
696 | #elif defined(SECOND) |
697 | struct S3 { |
698 | int FirstBody(); |
699 | }; |
700 | #else |
701 | S3 s3; |
702 | // expected-error@first.h:* {{'MethodBody::S3' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstBody' with body}} |
703 | // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstBody' with no body}} |
704 | #endif |
705 | |
706 | #if defined(FIRST) |
707 | struct S4 { |
708 | int SecondBody(); |
709 | }; |
710 | #elif defined(SECOND) |
711 | struct S4 { |
712 | int SecondBody() { return 0; } |
713 | }; |
714 | #else |
715 | S4 s4; |
716 | // 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}} |
717 | // expected-note@second.h:* {{but in 'SecondModule' found method 'SecondBody' with body}} |
718 | #endif |
719 | |
720 | #if defined(FIRST) |
721 | struct S5 { |
722 | int FirstBodySecondOutOfLine() { return 0; } |
723 | }; |
724 | #elif defined(SECOND) |
725 | struct S5 { |
726 | int FirstBodySecondOutOfLine(); |
727 | }; |
728 | int S5::FirstBodySecondOutOfLine() { return 0; } |
729 | #else |
730 | S5 s5; |
731 | // 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}} |
732 | // expected-note@first.h:* {{but in 'FirstModule' found method 'FirstBodySecondOutOfLine' with body}} |
733 | #endif |
734 | |
735 | #if defined(FIRST) |
736 | struct S6 { |
737 | int FirstOutOfLineSecondBody(); |
738 | }; |
739 | int S6::FirstOutOfLineSecondBody() { return 0; } |
740 | #elif defined(SECOND) |
741 | struct S6 { |
742 | int FirstOutOfLineSecondBody() { return 0; } |
743 | }; |
744 | #else |
745 | S6 s6; |
746 | // 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}} |
747 | // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstOutOfLineSecondBody' with body}} |
748 | #endif |
749 | |
750 | #if defined(FIRST) |
751 | struct S7 { |
752 | int BothOutOfLine(); |
753 | }; |
754 | int S7::BothOutOfLine() { return 1; } |
755 | #elif defined(SECOND) |
756 | struct S7 { |
757 | int BothOutOfLine(); |
758 | }; |
759 | int S7::BothOutOfLine() { return 0; } |
760 | #else |
761 | S7 s7; |
762 | // expected-error@second.h:* {{'MethodBody::S7::BothOutOfLine' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
763 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
764 | #endif |
765 | |
766 | #if defined(FIRST) |
767 | struct S8 { |
768 | int FirstBodySecondOutOfLine() { return 0; } |
769 | }; |
770 | #elif defined(SECOND) |
771 | struct S8 { |
772 | int FirstBodySecondOutOfLine(); |
773 | }; |
774 | int S8::FirstBodySecondOutOfLine() { return 1; } |
775 | #else |
776 | S8 s8; |
777 | // 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}} |
778 | // expected-note@first.h:* {{but in 'FirstModule' found method 'FirstBodySecondOutOfLine' with body}} |
779 | #endif |
780 | |
781 | #if defined(FIRST) |
782 | struct S9 { |
783 | int FirstOutOfLineSecondBody(); |
784 | }; |
785 | int S9::FirstOutOfLineSecondBody() { return 1; } |
786 | #elif defined(SECOND) |
787 | struct S9 { |
788 | int FirstOutOfLineSecondBody() { return 0; } |
789 | }; |
790 | #else |
791 | S9 s9; |
792 | // 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}} |
793 | // expected-note@second.h:* {{but in 'SecondModule' found method 'FirstOutOfLineSecondBody' with body}} |
794 | #endif |
795 | |
796 | #if defined(FIRST) |
797 | struct S10 { |
798 | S10(int); |
799 | S10() = delete; |
800 | }; |
801 | #elif defined(SECOND) |
802 | struct S10 { |
803 | S10(int); |
804 | S10(); |
805 | }; |
806 | #else |
807 | S10 s10(10); |
808 | // expected-error@first.h:* {{'MethodBody::S10' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is deleted}} |
809 | // expected-note@second.h:* {{but in 'SecondModule' found constructor is not deleted}} |
810 | #endif |
811 | |
812 | #if defined(FIRST) |
813 | struct S11 { |
814 | S11() = default; |
815 | }; |
816 | #elif defined(SECOND) |
817 | struct S11 { |
818 | S11(); |
819 | }; |
820 | #else |
821 | S11 s11; |
822 | // expected-error@first.h:* {{'MethodBody::S11' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is defaulted}} |
823 | // expected-note@second.h:* {{but in 'SecondModule' found constructor is not defaulted}} |
824 | #endif |
825 | |
826 | #define DECLS(CLASSNAME) \ |
827 | CLASSNAME() = default; \ |
828 | ~CLASSNAME() = delete; \ |
829 | void A(); \ |
830 | void B() { return; }; \ |
831 | void C(); \ |
832 | void D(); |
833 | |
834 | #define OUTOFLINEDEFS(CLASSNAME) \ |
835 | void CLASSNAME::C() {} \ |
836 | void CLASSNAME::D() { return; } |
837 | |
838 | #if defined(FIRST) || defined(SECOND) |
839 | struct Valid1 { |
840 | DECLS(Valid1) |
841 | }; |
842 | OUTOFLINEDEFS(Valid1) |
843 | #else |
844 | Valid1* v1; |
845 | #endif |
846 | |
847 | #if defined(FIRST) || defined(SECOND) |
848 | struct Invalid1 { |
849 | DECLS(Invalid1) |
850 | ACCESS |
851 | }; |
852 | OUTOFLINEDEFS(Invalid1) |
853 | #else |
854 | Invalid1* i1; |
855 | // expected-error@first.h:* {{'MethodBody::Invalid1' has different definitions in different modules; first difference is definition in module 'FirstModule' found public access specifier}} |
856 | // expected-note@second.h:* {{but in 'SecondModule' found private access specifier}} |
857 | #endif |
858 | #undef DECLS |
859 | } // namespace MethodBody |
860 | |
861 | namespace Constructor { |
862 | #if defined(FIRST) |
863 | struct S1 { |
864 | S1() {} |
865 | void foo() {} |
866 | }; |
867 | #elif defined(SECOND) |
868 | struct S1 { |
869 | void foo() {} |
870 | S1() {} |
871 | }; |
872 | #else |
873 | S1 s1; |
874 | // expected-error@second.h:* {{'Constructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'foo'}} |
875 | // expected-note@first.h:* {{but in 'FirstModule' found constructor}} |
876 | #endif |
877 | |
878 | #if defined(FIRST) |
879 | struct S2 { |
880 | S2(int) {} |
881 | S2(int, int) {} |
882 | }; |
883 | #elif defined(SECOND) |
884 | struct S2 { |
885 | S2(int, int) {} |
886 | S2(int) {} |
887 | }; |
888 | #else |
889 | S2* s2; |
890 | // 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}} |
891 | // expected-note@first.h:* {{but in 'FirstModule' found constructor that has 1 parameter}} |
892 | #endif |
893 | |
894 | #define DECLS(CLASS) \ |
895 | CLASS(int); \ |
896 | CLASS(double); \ |
897 | CLASS(int, int); |
898 | |
899 | #if defined(FIRST) || defined(SECOND) |
900 | struct Valid1 { |
901 | DECLS(Valid1) |
902 | }; |
903 | #else |
904 | Valid1* v1; |
905 | #endif |
906 | |
907 | #if defined(FIRST) || defined(SECOND) |
908 | struct Invalid1 { |
909 | DECLS(Invalid1) |
910 | ACCESS |
911 | }; |
912 | #else |
913 | Invalid1* i1; |
914 | // expected-error@second.h:* {{'Constructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
915 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
916 | #endif |
917 | #undef DECLS |
918 | } // namespace Constructor |
919 | |
920 | namespace Destructor { |
921 | #if defined(FIRST) |
922 | struct S1 { |
923 | ~S1() {} |
924 | S1() {} |
925 | }; |
926 | #elif defined(SECOND) |
927 | struct S1 { |
928 | S1() {} |
929 | ~S1() {} |
930 | }; |
931 | #else |
932 | S1 s1; |
933 | // expected-error@second.h:* {{'Destructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor}} |
934 | // expected-note@first.h:* {{but in 'FirstModule' found destructor}} |
935 | #endif |
936 | |
937 | #if defined(FIRST) |
938 | struct S2 { |
939 | virtual ~S2() {} |
940 | void foo() {} |
941 | }; |
942 | #elif defined(SECOND) |
943 | struct S2 { |
944 | ~S2() {} |
945 | virtual void foo() {} |
946 | }; |
947 | #else |
948 | S2 s2; |
949 | // expected-error@second.h:* {{'Destructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found destructor is not virtual}} |
950 | // expected-note@first.h:* {{but in 'FirstModule' found destructor is virtual}} |
951 | #endif |
952 | |
953 | #if defined(FIRST) || defined(SECOND) |
954 | struct Valid1 { |
955 | ~Valid1(); |
956 | }; |
957 | #else |
958 | Valid1 v1; |
959 | #endif |
960 | |
961 | #if defined(FIRST) || defined(SECOND) |
962 | struct Invalid1 { |
963 | ~Invalid1(); |
964 | ACCESS |
965 | }; |
966 | #else |
967 | Invalid1 i1; |
968 | // expected-error@second.h:* {{'Destructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
969 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
970 | #endif |
971 | |
972 | #if defined(FIRST) || defined(SECOND) |
973 | struct Valid2 { |
974 | virtual ~Valid2(); |
975 | }; |
976 | #else |
977 | Valid2 v2; |
978 | #endif |
979 | |
980 | #if defined(FIRST) || defined(SECOND) |
981 | struct Invalid2 { |
982 | virtual ~Invalid2(); |
983 | ACCESS |
984 | }; |
985 | #else |
986 | Invalid2 i2; |
987 | // expected-error@second.h:* {{'Destructor::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
988 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
989 | #endif |
990 | } // namespace Destructor |
991 | |
992 | namespace TypeDef { |
993 | #if defined(FIRST) |
994 | struct S1 { |
995 | typedef int a; |
996 | }; |
997 | #elif defined(SECOND) |
998 | struct S1 { |
999 | typedef double a; |
1000 | }; |
1001 | #else |
1002 | S1 s1; |
1003 | // expected-error@first.h:* {{'TypeDef::S1::a' from module 'FirstModule' is not present in definition of 'TypeDef::S1' in module 'SecondModule'}} |
1004 | // expected-note@second.h:* {{declaration of 'a' does not match}} |
1005 | #endif |
1006 | |
1007 | #if defined(FIRST) |
1008 | struct S2 { |
1009 | typedef int a; |
1010 | }; |
1011 | #elif defined(SECOND) |
1012 | struct S2 { |
1013 | typedef int b; |
1014 | }; |
1015 | #else |
1016 | S2 s2; |
1017 | // expected-error@first.h:* {{'TypeDef::S2::a' from module 'FirstModule' is not present in definition of 'TypeDef::S2' in module 'SecondModule'}} |
1018 | // expected-note@second.h:* {{definition has no member 'a'}} |
1019 | #endif |
1020 | |
1021 | #if defined(FIRST) |
1022 | typedef int T; |
1023 | struct S3 { |
1024 | typedef T a; |
1025 | }; |
1026 | #elif defined(SECOND) |
1027 | typedef double T; |
1028 | struct S3 { |
1029 | typedef T a; |
1030 | }; |
1031 | #else |
1032 | S3 s3; |
1033 | // expected-error@first.h:* {{'TypeDef::S3::a' from module 'FirstModule' is not present in definition of 'TypeDef::S3' in module 'SecondModule'}} |
1034 | // expected-note@second.h:* {{declaration of 'a' does not match}} |
1035 | #endif |
1036 | |
1037 | #if defined(FIRST) |
1038 | struct S4 { |
1039 | typedef int a; |
1040 | typedef int b; |
1041 | }; |
1042 | #elif defined(SECOND) |
1043 | struct S4 { |
1044 | typedef int b; |
1045 | typedef int a; |
1046 | }; |
1047 | #else |
1048 | S4 s4; |
1049 | // expected-error@second.h:* {{'TypeDef::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found typedef name 'b'}} |
1050 | // expected-note@first.h:* {{but in 'FirstModule' found typedef name 'a'}} |
1051 | #endif |
1052 | |
1053 | #if defined(FIRST) |
1054 | struct S5 { |
1055 | typedef int a; |
1056 | typedef int b; |
1057 | int x; |
1058 | }; |
1059 | #elif defined(SECOND) |
1060 | struct S5 { |
1061 | int x; |
1062 | typedef int b; |
1063 | typedef int a; |
1064 | }; |
1065 | #else |
1066 | S5 s5; |
1067 | // expected-error@second.h:* {{'TypeDef::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}} |
1068 | // expected-note@first.h:* {{but in 'FirstModule' found typedef}} |
1069 | #endif |
1070 | |
1071 | #if defined(FIRST) |
1072 | typedef float F; |
1073 | struct S6 { |
1074 | typedef int a; |
1075 | typedef F b; |
1076 | }; |
1077 | #elif defined(SECOND) |
1078 | struct S6 { |
1079 | typedef int a; |
1080 | typedef float b; |
1081 | }; |
1082 | #else |
1083 | S6 s6; |
1084 | // 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'}} |
1085 | // expected-note@first.h:* {{but in 'FirstModule' found typedef 'b' with different underlying type 'TypeDef::F' (aka 'float')}} |
1086 | #endif |
1087 | |
1088 | #define DECLS \ |
1089 | typedef int A; \ |
1090 | typedef double B; \ |
1091 | typedef I C; |
1092 | |
1093 | #if defined(FIRST) || defined(SECOND) |
1094 | typedef int I; |
1095 | #endif |
1096 | |
1097 | #if defined(FIRST) || defined(SECOND) |
1098 | struct Valid1 { |
1099 | DECLS |
1100 | }; |
1101 | #else |
1102 | Valid1 v1; |
1103 | #endif |
1104 | |
1105 | #if defined(FIRST) || defined(SECOND) |
1106 | struct Invalid1 { |
1107 | DECLS |
1108 | ACCESS |
1109 | }; |
1110 | #else |
1111 | Invalid1 i1; |
1112 | // expected-error@second.h:* {{'TypeDef::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1113 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1114 | #endif |
1115 | #undef DECLS |
1116 | } // namespace TypeDef |
1117 | |
1118 | namespace Using { |
1119 | #if defined(FIRST) |
1120 | struct S1 { |
1121 | using a = int; |
1122 | }; |
1123 | #elif defined(SECOND) |
1124 | struct S1 { |
1125 | using a = double; |
1126 | }; |
1127 | #else |
1128 | S1 s1; |
1129 | // expected-error@first.h:* {{'Using::S1::a' from module 'FirstModule' is not present in definition of 'Using::S1' in module 'SecondModule'}} |
1130 | // expected-note@second.h:* {{declaration of 'a' does not match}} |
1131 | #endif |
1132 | |
1133 | #if defined(FIRST) |
1134 | struct S2 { |
1135 | using a = int; |
1136 | }; |
1137 | #elif defined(SECOND) |
1138 | struct S2 { |
1139 | using b = int; |
1140 | }; |
1141 | #else |
1142 | S2 s2; |
1143 | // expected-error@first.h:* {{'Using::S2::a' from module 'FirstModule' is not present in definition of 'Using::S2' in module 'SecondModule'}} |
1144 | // expected-note@second.h:* {{definition has no member 'a'}} |
1145 | #endif |
1146 | |
1147 | #if defined(FIRST) |
1148 | typedef int T; |
1149 | struct S3 { |
1150 | using a = T; |
1151 | }; |
1152 | #elif defined(SECOND) |
1153 | typedef double T; |
1154 | struct S3 { |
1155 | using a = T; |
1156 | }; |
1157 | #else |
1158 | S3 s3; |
1159 | // expected-error@first.h:* {{'Using::S3::a' from module 'FirstModule' is not present in definition of 'Using::S3' in module 'SecondModule'}} |
1160 | // expected-note@second.h:* {{declaration of 'a' does not match}} |
1161 | #endif |
1162 | |
1163 | #if defined(FIRST) |
1164 | struct S4 { |
1165 | using a = int; |
1166 | using b = int; |
1167 | }; |
1168 | #elif defined(SECOND) |
1169 | struct S4 { |
1170 | using b = int; |
1171 | using a = int; |
1172 | }; |
1173 | #else |
1174 | S4 s4; |
1175 | // expected-error@second.h:* {{'Using::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias name 'b'}} |
1176 | // expected-note@first.h:* {{but in 'FirstModule' found type alias name 'a'}} |
1177 | #endif |
1178 | |
1179 | #if defined(FIRST) |
1180 | struct S5 { |
1181 | using a = int; |
1182 | using b = int; |
1183 | int x; |
1184 | }; |
1185 | #elif defined(SECOND) |
1186 | struct S5 { |
1187 | int x; |
1188 | using b = int; |
1189 | using a = int; |
1190 | }; |
1191 | #else |
1192 | S5 s5; |
1193 | // expected-error@second.h:* {{'Using::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}} |
1194 | // expected-note@first.h:* {{but in 'FirstModule' found type alias}} |
1195 | #endif |
1196 | |
1197 | #if defined(FIRST) |
1198 | typedef float F; |
1199 | struct S6 { |
1200 | using a = int; |
1201 | using b = F; |
1202 | }; |
1203 | #elif defined(SECOND) |
1204 | struct S6 { |
1205 | using a = int; |
1206 | using b = float; |
1207 | }; |
1208 | #else |
1209 | S6 s6; |
1210 | // 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'}} |
1211 | // expected-note@first.h:* {{but in 'FirstModule' found type alias 'b' with different underlying type 'Using::F' (aka 'float')}} |
1212 | #endif |
1213 | |
1214 | #if defined(FIRST) || defined(SECOND) |
1215 | using I = int; |
1216 | #endif |
1217 | |
1218 | #define DECLS \ |
1219 | using A = int; \ |
1220 | using B = double; \ |
1221 | using C = I; |
1222 | |
1223 | #if defined(FIRST) || defined(SECOND) |
1224 | struct Valid1 { |
1225 | DECLS |
1226 | }; |
1227 | #else |
1228 | Valid1 v1; |
1229 | #endif |
1230 | |
1231 | #if defined(FIRST) || defined(SECOND) |
1232 | struct Invalid1 { |
1233 | DECLS |
1234 | ACCESS |
1235 | }; |
1236 | #else |
1237 | Invalid1 i1; |
1238 | // expected-error@second.h:* {{'Using::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1239 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1240 | #endif |
1241 | #undef DECLS |
1242 | } // namespace Using |
1243 | |
1244 | namespace RecordType { |
1245 | #if defined(FIRST) |
1246 | struct B1 {}; |
1247 | struct S1 { |
1248 | B1 x; |
1249 | }; |
1250 | #elif defined(SECOND) |
1251 | struct A1 {}; |
1252 | struct S1 { |
1253 | A1 x; |
1254 | }; |
1255 | #else |
1256 | S1 s1; |
1257 | // expected-error@first.h:* {{'RecordType::S1::x' from module 'FirstModule' is not present in definition of 'RecordType::S1' in module 'SecondModule'}} |
1258 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1259 | #endif |
1260 | |
1261 | #define DECLS \ |
1262 | Foo F; |
1263 | |
1264 | #if defined(FIRST) || defined(SECOND) |
1265 | struct Foo {}; |
1266 | #endif |
1267 | |
1268 | #if defined(FIRST) || defined(SECOND) |
1269 | struct Valid1 { |
1270 | DECLS |
1271 | }; |
1272 | #else |
1273 | Valid1 v1; |
1274 | #endif |
1275 | |
1276 | #if defined(FIRST) || defined(SECOND) |
1277 | struct Invalid1 { |
1278 | DECLS |
1279 | ACCESS |
1280 | }; |
1281 | #else |
1282 | Invalid1 i1; |
1283 | // expected-error@second.h:* {{'RecordType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1284 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1285 | #endif |
1286 | #undef DECLS |
1287 | } // namespace RecordType |
1288 | |
1289 | namespace DependentType { |
1290 | #if defined(FIRST) |
1291 | template <class T> |
1292 | class S1 { |
1293 | typename T::typeA x; |
1294 | }; |
1295 | #elif defined(SECOND) |
1296 | template <class T> |
1297 | class S1 { |
1298 | typename T::typeB x; |
1299 | }; |
1300 | #else |
1301 | template<class T> |
1302 | using U1 = S1<T>; |
1303 | // expected-error@first.h:* {{'DependentType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T>' in module 'SecondModule'}} |
1304 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1305 | #endif |
1306 | |
1307 | #define DECLS \ |
1308 | typename T::typeA x; |
1309 | |
1310 | #if defined(FIRST) || defined(SECOND) |
1311 | template <class T> |
1312 | struct Valid1 { |
1313 | DECLS |
1314 | }; |
1315 | #else |
1316 | template <class T> |
1317 | using V1 = Valid1<T>; |
1318 | #endif |
1319 | |
1320 | #if defined(FIRST) || defined(SECOND) |
1321 | template <class T> |
1322 | struct Invalid1 { |
1323 | DECLS |
1324 | ACCESS |
1325 | }; |
1326 | #else |
1327 | template <class T> |
1328 | using I1 = Invalid1<T>; |
1329 | // expected-error@second.h:* {{'DependentType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1330 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1331 | #endif |
1332 | #undef DECLS |
1333 | } // namespace DependentType |
1334 | |
1335 | namespace ElaboratedType { |
1336 | #if defined(FIRST) |
1337 | namespace N1 { using type = double; } |
1338 | struct S1 { |
1339 | N1::type x; |
1340 | }; |
1341 | #elif defined(SECOND) |
1342 | namespace N1 { using type = int; } |
1343 | struct S1 { |
1344 | N1::type x; |
1345 | }; |
1346 | #else |
1347 | S1 s1; |
1348 | // expected-error@first.h:* {{'ElaboratedType::S1::x' from module 'FirstModule' is not present in definition of 'ElaboratedType::S1' in module 'SecondModule'}} |
1349 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1350 | #endif |
1351 | |
1352 | #define DECLS \ |
1353 | NS::type x; |
1354 | |
1355 | #if defined(FIRST) || defined(SECOND) |
1356 | namespace NS { using type = float; } |
1357 | #endif |
1358 | |
1359 | #if defined(FIRST) || defined(SECOND) |
1360 | struct Valid1 { |
1361 | DECLS |
1362 | }; |
1363 | #else |
1364 | Valid1 v1; |
1365 | #endif |
1366 | |
1367 | #if defined(FIRST) || defined(SECOND) |
1368 | struct Invalid1 { |
1369 | DECLS |
1370 | ACCESS |
1371 | }; |
1372 | #else |
1373 | Invalid1 i1; |
1374 | // expected-error@second.h:* {{'ElaboratedType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1375 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1376 | #endif |
1377 | #undef DECLS |
1378 | } // namespace ElaboratedType |
1379 | |
1380 | namespace Enum { |
1381 | #if defined(FIRST) |
1382 | enum A1 {}; |
1383 | struct S1 { |
1384 | A1 x; |
1385 | }; |
1386 | #elif defined(SECOND) |
1387 | enum A2 {}; |
1388 | struct S1 { |
1389 | A2 x; |
1390 | }; |
1391 | #else |
1392 | S1 s1; |
1393 | // expected-error@first.h:* {{'Enum::S1::x' from module 'FirstModule' is not present in definition of 'Enum::S1' in module 'SecondModule'}} |
1394 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1395 | #endif |
1396 | |
1397 | #define DECLS \ |
1398 | E e = E1; |
1399 | |
1400 | #if defined(FIRST) || defined(SECOND) |
1401 | enum E { E1, E2 }; |
1402 | #endif |
1403 | |
1404 | #if defined(FIRST) || defined(SECOND) |
1405 | struct Valid1 { |
1406 | DECLS |
1407 | }; |
1408 | #else |
1409 | Valid1 v1; |
1410 | #endif |
1411 | |
1412 | #if defined(FIRST) || defined(SECOND) |
1413 | struct Invalid1 { |
1414 | DECLS |
1415 | ACCESS |
1416 | }; |
1417 | #else |
1418 | Invalid1 i1; |
1419 | // expected-error@second.h:* {{'Enum::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1420 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1421 | #endif |
1422 | #undef DECLS |
1423 | } |
1424 | |
1425 | namespace NestedNamespaceSpecifier { |
1426 | #if defined(FIRST) |
1427 | namespace LevelA1 { |
1428 | using Type = int; |
1429 | } |
1430 | |
1431 | struct S1 { |
1432 | LevelA1::Type x; |
1433 | }; |
1434 | # elif defined(SECOND) |
1435 | namespace LevelB1 { |
1436 | namespace LevelC1 { |
1437 | using Type = int; |
1438 | } |
1439 | } |
1440 | |
1441 | struct S1 { |
1442 | LevelB1::LevelC1::Type x; |
1443 | }; |
1444 | #else |
1445 | S1 s1; |
1446 | // 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')}} |
1447 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA1::Type' (aka 'int')}} |
1448 | #endif |
1449 | |
1450 | #if defined(FIRST) |
1451 | namespace LevelA2 { using Type = int; } |
1452 | struct S2 { |
1453 | LevelA2::Type x; |
1454 | }; |
1455 | # elif defined(SECOND) |
1456 | struct S2 { |
1457 | int x; |
1458 | }; |
1459 | #else |
1460 | S2 s2; |
1461 | // 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'}} |
1462 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA2::Type' (aka 'int')}} |
1463 | #endif |
1464 | |
1465 | namespace LevelA3 { using Type = int; } |
1466 | namespace LevelB3 { using Type = int; } |
1467 | #if defined(FIRST) |
1468 | struct S3 { |
1469 | LevelA3::Type x; |
1470 | }; |
1471 | # elif defined(SECOND) |
1472 | struct S3 { |
1473 | LevelB3::Type x; |
1474 | }; |
1475 | #else |
1476 | S3 s3; |
1477 | // 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')}} |
1478 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'LevelA3::Type' (aka 'int')}} |
1479 | #endif |
1480 | |
1481 | #if defined(FIRST) |
1482 | struct TA4 { using Type = int; }; |
1483 | struct S4 { |
1484 | TA4::Type x; |
1485 | }; |
1486 | # elif defined(SECOND) |
1487 | struct TB4 { using Type = int; }; |
1488 | struct S4 { |
1489 | TB4::Type x; |
1490 | }; |
1491 | #else |
1492 | S4 s4; |
1493 | // 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')}} |
1494 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'TA4::Type' (aka 'int')}} |
1495 | #endif |
1496 | |
1497 | #if defined(FIRST) |
1498 | struct T5 { using Type = int; }; |
1499 | struct S5 { |
1500 | T5::Type x; |
1501 | }; |
1502 | # elif defined(SECOND) |
1503 | namespace T5 { using Type = int; }; |
1504 | struct S5 { |
1505 | T5::Type x; |
1506 | }; |
1507 | #else |
1508 | S5 s5; |
1509 | // 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')}} |
1510 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'T5::Type' (aka 'int')}} |
1511 | #endif |
1512 | |
1513 | #if defined(FIRST) |
1514 | namespace N6 {using I = int;} |
1515 | struct S6 { |
1516 | NestedNamespaceSpecifier::N6::I x; |
1517 | }; |
1518 | # elif defined(SECOND) |
1519 | using I = int; |
1520 | struct S6 { |
1521 | ::NestedNamespaceSpecifier::I x; |
1522 | }; |
1523 | #else |
1524 | S6 s6; |
1525 | // 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')}} |
1526 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'NestedNamespaceSpecifier::N6::I' (aka 'int')}} |
1527 | #endif |
1528 | |
1529 | #if defined(FIRST) |
1530 | template <class T, class U> |
1531 | class S7 { |
1532 | typename T::type *x = {}; |
1533 | int z = x->T::foo(); |
1534 | }; |
1535 | #elif defined(SECOND) |
1536 | template <class T, class U> |
1537 | class S7 { |
1538 | typename T::type *x = {}; |
1539 | int z = x->U::foo(); |
1540 | }; |
1541 | #else |
1542 | template <class T, class U> |
1543 | using U7 = S7<T, U>; |
1544 | // 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}} |
1545 | // expected-note@first.h:* {{but in 'FirstModule' found field 'z' with a different initializer}} |
1546 | #endif |
1547 | |
1548 | #if defined(FIRST) |
1549 | template <class T> |
1550 | class S8 { |
1551 | int x = T::template X<int>::value; |
1552 | }; |
1553 | #elif defined(SECOND) |
1554 | template <class T> |
1555 | class S8 { |
1556 | int x = T::template Y<int>::value; |
1557 | }; |
1558 | #else |
1559 | template <class T> |
1560 | using U8 = S8<T>; |
1561 | // 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}} |
1562 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}} |
1563 | #endif |
1564 | |
1565 | #if defined(FIRST) |
1566 | namespace N9 { using I = int; } |
1567 | namespace O9 = N9; |
1568 | struct S9 { |
1569 | O9::I x; |
1570 | }; |
1571 | #elif defined(SECOND) |
1572 | namespace N9 { using I = int; } |
1573 | namespace P9 = N9; |
1574 | struct S9 { |
1575 | P9::I x; |
1576 | }; |
1577 | #else |
1578 | S9 s9; |
1579 | // 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')}} |
1580 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'O9::I' (aka 'int')}} |
1581 | #endif |
1582 | |
1583 | namespace N10 { |
1584 | #if defined(FIRST) |
1585 | inline namespace A { struct X {}; } |
1586 | struct S10 { |
1587 | A::X x; |
1588 | }; |
1589 | #elif defined(SECOND) |
1590 | inline namespace B { struct X {}; } |
1591 | struct S10 { |
1592 | B::X x; |
1593 | }; |
1594 | #else |
1595 | S10 s10; |
1596 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::N10::S10::x' from module 'SecondModule' is not present in definition of 'NestedNamespaceSpecifier::N10::S10' in module 'FirstModule'}} |
1597 | // expected-note@first.h:* {{declaration of 'x' does not match}} |
1598 | #endif |
1599 | } |
1600 | |
1601 | #define DECLS \ |
1602 | NS1::Type a; \ |
1603 | NS1::NS2::Type b; \ |
1604 | NS1::S c; \ |
1605 | NS3::Type d; |
1606 | |
1607 | #if defined(FIRST) || defined(SECOND) |
1608 | namespace NS1 { |
1609 | using Type = int; |
1610 | namespace NS2 { |
1611 | using Type = double; |
1612 | } |
1613 | struct S {}; |
1614 | } |
1615 | namespace NS3 = NS1; |
1616 | #endif |
1617 | |
1618 | #if defined(FIRST) || defined(SECOND) |
1619 | struct Valid1 { |
1620 | DECLS |
1621 | }; |
1622 | #else |
1623 | Valid1 v1; |
1624 | #endif |
1625 | |
1626 | #if defined(FIRST) || defined(SECOND) |
1627 | struct Invalid1 { |
1628 | DECLS |
1629 | ACCESS |
1630 | }; |
1631 | #else |
1632 | Invalid1 i1; |
1633 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1634 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1635 | #endif |
1636 | #undef DECLS |
1637 | |
1638 | #define DECLS \ |
1639 | typename T::type *x = {}; \ |
1640 | int y = x->T::foo(); \ |
1641 | int z = U::template X<int>::value; |
1642 | |
1643 | #if defined(FIRST) || defined(SECOND) |
1644 | template <class T, class U> |
1645 | struct Valid2 { |
1646 | DECLS |
1647 | }; |
1648 | #else |
1649 | template <class T, class U> |
1650 | using V2 = Valid2<T, U>; |
1651 | #endif |
1652 | |
1653 | #if defined(FIRST) || defined(SECOND) |
1654 | template <class T, class U> |
1655 | struct Invalid2 { |
1656 | DECLS |
1657 | ACCESS |
1658 | }; |
1659 | #else |
1660 | template <class T, class U> |
1661 | using I2 = Invalid2<T, U>; |
1662 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1663 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1664 | #endif |
1665 | #undef DECLS |
1666 | } // namespace NestedNamespaceSpecifier |
1667 | |
1668 | namespace TemplateSpecializationType { |
1669 | #if defined(FIRST) |
1670 | template <class T1> struct U1 {}; |
1671 | struct S1 { |
1672 | U1<int> u; |
1673 | }; |
1674 | #elif defined(SECOND) |
1675 | template <class T1, class T2> struct U1 {}; |
1676 | struct S1 { |
1677 | U1<int, int> u; |
1678 | }; |
1679 | #else |
1680 | S1 s1; |
1681 | // expected-error@first.h:* {{'TemplateSpecializationType::S1::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S1' in module 'SecondModule'}} |
1682 | // expected-note@second.h:* {{declaration of 'u' does not match}} |
1683 | #endif |
1684 | |
1685 | #if defined(FIRST) |
1686 | template <class T1> struct U2 {}; |
1687 | struct S2 { |
1688 | U2<int> u; |
1689 | }; |
1690 | #elif defined(SECOND) |
1691 | template <class T1> struct V1 {}; |
1692 | struct S2 { |
1693 | V1<int> u; |
1694 | }; |
1695 | #else |
1696 | S2 s2; |
1697 | // expected-error@first.h:* {{'TemplateSpecializationType::S2::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S2' in module 'SecondModule'}} |
1698 | // expected-note@second.h:* {{declaration of 'u' does not match}} |
1699 | #endif |
1700 | |
1701 | #define DECLS \ |
1702 | OneTemplateArg<int> x; \ |
1703 | OneTemplateArg<double> y; \ |
1704 | OneTemplateArg<char *> z; \ |
1705 | TwoTemplateArgs<int, int> a; \ |
1706 | TwoTemplateArgs<double, float> b; \ |
1707 | TwoTemplateArgs<short *, char> c; |
1708 | |
1709 | #if defined(FIRST) || defined(SECOND) |
1710 | template <class T> struct OneTemplateArg {}; |
1711 | template <class T, class U> struct TwoTemplateArgs {}; |
1712 | #endif |
1713 | |
1714 | #if defined(FIRST) || defined(SECOND) |
1715 | struct Valid1 { |
1716 | DECLS |
1717 | }; |
1718 | #else |
1719 | Valid1 v1; |
1720 | #endif |
1721 | |
1722 | #if defined(FIRST) || defined(SECOND) |
1723 | struct Invalid1 { |
1724 | DECLS |
1725 | ACCESS |
1726 | }; |
1727 | #else |
1728 | Invalid1 i1; |
1729 | // expected-error@second.h:* {{'TemplateSpecializationType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1730 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1731 | #endif |
1732 | #undef DECLS |
1733 | } // namespace TemplateSpecializationType |
1734 | |
1735 | namespace TemplateArgument { |
1736 | #if defined(FIRST) |
1737 | template <class> struct U1{}; |
1738 | struct S1 { |
1739 | U1<int> x; |
1740 | }; |
1741 | #elif defined(SECOND) |
1742 | template <int> struct U1{}; |
1743 | struct S1 { |
1744 | U1<1> x; |
1745 | }; |
1746 | #else |
1747 | S1 s1; |
1748 | // expected-error@first.h:* {{'TemplateArgument::S1::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 'SecondModule'}} |
1749 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1750 | #endif |
1751 | |
1752 | #if defined(FIRST) |
1753 | template <int> struct U2{}; |
1754 | struct S2 { |
1755 | using T = U2<2>; |
1756 | }; |
1757 | #elif defined(SECOND) |
1758 | template <int> struct U2{}; |
1759 | struct S2 { |
1760 | using T = U2<(2)>; |
1761 | }; |
1762 | #else |
1763 | S2 s2; |
1764 | // 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)>'}} |
1765 | // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U2<2>'}} |
1766 | #endif |
1767 | |
1768 | #if defined(FIRST) |
1769 | template <int> struct U3{}; |
1770 | struct S3 { |
1771 | using T = U3<2>; |
1772 | }; |
1773 | #elif defined(SECOND) |
1774 | template <int> struct U3{}; |
1775 | struct S3 { |
1776 | using T = U3<1 + 1>; |
1777 | }; |
1778 | #else |
1779 | S3 s3; |
1780 | // 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>'}} |
1781 | // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U3<2>'}} |
1782 | #endif |
1783 | |
1784 | #if defined(FIRST) |
1785 | template<class> struct T4a {}; |
1786 | template <template <class> class T> struct U4 {}; |
1787 | struct S4 { |
1788 | U4<T4a> x; |
1789 | }; |
1790 | #elif defined(SECOND) |
1791 | template<class> struct T4b {}; |
1792 | template <template <class> class T> struct U4 {}; |
1793 | struct S4 { |
1794 | U4<T4b> x; |
1795 | }; |
1796 | #else |
1797 | S4 s4; |
1798 | // expected-error@first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}} |
1799 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1800 | #endif |
1801 | |
1802 | #if defined(FIRST) |
1803 | template <class T> struct U5 {}; |
1804 | struct S5 { |
1805 | U5<int> x; |
1806 | }; |
1807 | #elif defined(SECOND) |
1808 | template <class T> struct U5 {}; |
1809 | struct S5 { |
1810 | U5<short> x; |
1811 | }; |
1812 | #else |
1813 | S5 s5; |
1814 | // expected-error@first.h:* {{'TemplateArgument::S5::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S5' in module 'SecondModule'}} |
1815 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1816 | #endif |
1817 | |
1818 | #if defined(FIRST) |
1819 | template <class T> struct U6 {}; |
1820 | struct S6 { |
1821 | U6<int> x; |
1822 | U6<short> y; |
1823 | }; |
1824 | #elif defined(SECOND) |
1825 | template <class T> struct U6 {}; |
1826 | struct S6 { |
1827 | U6<short> y; |
1828 | U6<int> x; |
1829 | }; |
1830 | #else |
1831 | S6 s6; |
1832 | // expected-error@second.h:* {{'TemplateArgument::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}} |
1833 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x'}} |
1834 | #endif |
1835 | |
1836 | #if defined(FIRST) |
1837 | struct S7 { |
1838 | template<int> void run() {} |
1839 | template<> void run<1>() {} |
1840 | }; |
1841 | #elif defined(SECOND) |
1842 | struct S7 { |
1843 | template<int> void run() {} |
1844 | void run() {} |
1845 | }; |
1846 | #else |
1847 | S7 s7; |
1848 | // 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}} |
1849 | // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with template arguments}} |
1850 | #endif |
1851 | |
1852 | #if defined(FIRST) |
1853 | struct S8 { |
1854 | static int a, b; |
1855 | template<int&> void run() {} |
1856 | template<int&, int&> void run() {} |
1857 | template<> void run<a>() {} |
1858 | }; |
1859 | #elif defined(SECOND) |
1860 | struct S8 { |
1861 | static int a, b; |
1862 | template<int&> void run() {} |
1863 | template<int&, int&> void run() {} |
1864 | template<> void run<a, b>() {} |
1865 | }; |
1866 | #else |
1867 | S8 s8; |
1868 | // 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}} |
1869 | // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 1 template argument}} |
1870 | #endif |
1871 | |
1872 | #if defined(FIRST) |
1873 | struct S9 { |
1874 | static int a, b; |
1875 | template<int&> void run() {} |
1876 | template<> void run<a>() {} |
1877 | }; |
1878 | #elif defined(SECOND) |
1879 | struct S9 { |
1880 | static int a, b; |
1881 | template<int&> void run() {} |
1882 | template<> void run<b>() {} |
1883 | }; |
1884 | #else |
1885 | S9 s9; |
1886 | // 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}} |
1887 | // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 'a' for 1st template argument}} |
1888 | #endif |
1889 | |
1890 | #if defined(FIRST) |
1891 | struct S10 { |
1892 | static int a, b; |
1893 | template<int, int&...> void run() {} |
1894 | template<> void run<1, a>() {} |
1895 | }; |
1896 | #elif defined(SECOND) |
1897 | struct S10 { |
1898 | static int a, b; |
1899 | template<int, int&...> void run() {} |
1900 | template<> void run<1, b>() {} |
1901 | }; |
1902 | #else |
1903 | S10 s10; |
1904 | // 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}} |
1905 | // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 'a' for 2nd template argument}} |
1906 | #endif |
1907 | |
1908 | #if defined(FIRST) |
1909 | struct S11 { |
1910 | static int a, b; |
1911 | template<int, int&...> void run() {} |
1912 | template<> void run<1, a>() {} |
1913 | }; |
1914 | #elif defined(SECOND) |
1915 | struct S11 { |
1916 | static int a, b; |
1917 | template<int, int&...> void run() {} |
1918 | template<> void run<1, a, a>() {} |
1919 | }; |
1920 | #else |
1921 | S11 s11; |
1922 | // 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}} |
1923 | // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 2 template arguments}} |
1924 | #endif |
1925 | |
1926 | #define DECLS \ |
1927 | OneClass<int> a; \ |
1928 | OneInt<1> b; \ |
1929 | using c = OneClass<float>; \ |
1930 | using d = OneInt<2>; \ |
1931 | using e = OneInt<2 + 2>; \ |
1932 | OneTemplateClass<OneClass> f; \ |
1933 | OneTemplateInt<OneInt> g; \ |
1934 | static int i1, i2; \ |
1935 | template <int &> \ |
1936 | void Function() {} \ |
1937 | template <int &, int &> \ |
1938 | void Function() {} \ |
1939 | template <> \ |
1940 | void Function<i1>() {} \ |
1941 | template <> \ |
1942 | void Function<i2>() {} \ |
1943 | template <> \ |
1944 | void Function<i1, i2>() {} \ |
1945 | template <> \ |
1946 | void Function<i2, i1>() {} |
1947 | |
1948 | #if defined(FIRST) || defined(SECOND) |
1949 | template <class> struct OneClass{}; |
1950 | template <int> struct OneInt{}; |
1951 | template <template <class> class> struct OneTemplateClass{}; |
1952 | template <template <int> class> struct OneTemplateInt{}; |
1953 | #endif |
1954 | |
1955 | #if defined(FIRST) || defined(SECOND) |
1956 | struct Valid1 { |
1957 | DECLS |
1958 | }; |
1959 | #else |
1960 | Valid1 v1; |
1961 | #endif |
1962 | |
1963 | #if defined(FIRST) || defined(SECOND) |
1964 | struct Invalid1 { |
1965 | DECLS |
1966 | ACCESS |
1967 | }; |
1968 | #else |
1969 | Invalid1 i1; |
1970 | // expected-error@second.h:* {{'TemplateArgument::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
1971 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
1972 | #endif |
1973 | #undef DECLS |
1974 | } // namespace TemplateArgument |
1975 | |
1976 | namespace TemplateTypeParmType { |
1977 | #if defined(FIRST) |
1978 | template <class T1, class T2> |
1979 | struct S1 { |
1980 | T1 x; |
1981 | }; |
1982 | #elif defined(SECOND) |
1983 | template <class T1, class T2> |
1984 | struct S1 { |
1985 | T2 x; |
1986 | }; |
1987 | #else |
1988 | using TemplateTypeParmType::S1; |
1989 | // expected-error@first.h:* {{'TemplateTypeParmType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T1, T2>' in module 'SecondModule'}} |
1990 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
1991 | #endif |
1992 | |
1993 | #if defined(FIRST) |
1994 | template <int ...Ts> |
1995 | struct U2 {}; |
1996 | template <int T, int U> |
1997 | class S2 { |
1998 | typedef U2<U, T> type; |
1999 | type x; |
2000 | }; |
2001 | #elif defined(SECOND) |
2002 | template <int ...Ts> |
2003 | struct U2 {}; |
2004 | template <int T, int U> |
2005 | class S2 { |
2006 | typedef U2<T, U> type; |
2007 | type x; |
2008 | }; |
2009 | #else |
2010 | using TemplateTypeParmType::S2; |
2011 | // expected-error@first.h:* {{'TemplateTypeParmType::S2::x' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}} |
2012 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2013 | // expected-error@first.h:* {{'TemplateTypeParmType::S2::type' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}} |
2014 | // expected-note@second.h:* {{declaration of 'type' does not match}} |
2015 | #endif |
2016 | |
2017 | #define DECLS \ |
2018 | T t; \ |
2019 | U u; \ |
2020 | ParameterPack<T> a; \ |
2021 | ParameterPack<T, U> b; \ |
2022 | ParameterPack<U> c; \ |
2023 | ParameterPack<U, T> d; |
2024 | |
2025 | #if defined(FIRST) || defined(SECOND) |
2026 | template <class ...Ts> struct ParameterPack {}; |
2027 | #endif |
2028 | |
2029 | #if defined(FIRST) || defined(SECOND) |
2030 | template <class T, class U> |
2031 | struct Valid1 { |
2032 | DECLS |
2033 | }; |
2034 | #else |
2035 | using TemplateTypeParmType::Valid1; |
2036 | #endif |
2037 | |
2038 | #if defined(FIRST) || defined(SECOND) |
2039 | template <class T, class U> |
2040 | struct Invalid1 { |
2041 | DECLS |
2042 | ACCESS |
2043 | }; |
2044 | #else |
2045 | using TemplateTypeParmType::Invalid1; |
2046 | // expected-error@second.h:* {{'TemplateTypeParmType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
2047 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
2048 | #endif |
2049 | #undef DECLS |
2050 | } // namespace TemplateTypeParmType |
2051 | |
2052 | namespace VarDecl { |
2053 | #if defined(FIRST) |
2054 | struct S1 { |
2055 | static int x; |
2056 | static int y; |
2057 | }; |
2058 | #elif defined(SECOND) |
2059 | struct S1 { |
2060 | static int y; |
2061 | static int x; |
2062 | }; |
2063 | #else |
2064 | S1 s1; |
2065 | // 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'}} |
2066 | // expected-note@first.h:* {{but in 'FirstModule' found data member with name 'x'}} |
2067 | #endif |
2068 | |
2069 | #if defined(FIRST) |
2070 | struct S2 { |
2071 | static int x; |
2072 | }; |
2073 | #elif defined(SECOND) |
2074 | using I = int; |
2075 | struct S2 { |
2076 | static I x; |
2077 | }; |
2078 | #else |
2079 | S2 s2; |
2080 | // expected-error@second.h:* {{'VarDecl::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' with type 'VarDecl::I' (aka 'int')}} |
2081 | // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with different type 'int'}} |
2082 | #endif |
2083 | |
2084 | #if defined(FIRST) |
2085 | struct S3 { |
2086 | static const int x = 1; |
2087 | }; |
2088 | #elif defined(SECOND) |
2089 | struct S3 { |
2090 | static const int x; |
2091 | }; |
2092 | #else |
2093 | S3 s3; |
2094 | // 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}} |
2095 | // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' without an initializer}} |
2096 | #endif |
2097 | |
2098 | #if defined(FIRST) |
2099 | struct S4 { |
2100 | static const int x = 1; |
2101 | }; |
2102 | #elif defined(SECOND) |
2103 | struct S4 { |
2104 | static const int x = 2; |
2105 | }; |
2106 | #else |
2107 | S4 s4; |
2108 | // 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}} |
2109 | // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' with a different initializer}} |
2110 | #endif |
2111 | |
2112 | #if defined(FIRST) |
2113 | struct S5 { |
2114 | static const int x = 1; |
2115 | }; |
2116 | #elif defined(SECOND) |
2117 | struct S5 { |
2118 | static constexpr int x = 1; |
2119 | }; |
2120 | #else |
2121 | S5 s5; |
2122 | // 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}} |
2123 | // expected-note@first.h:* {{but in 'FirstModule' found data member 'x' is constexpr}} |
2124 | #endif |
2125 | |
2126 | #if defined(FIRST) |
2127 | struct S6 { |
2128 | static const int x = 1; |
2129 | }; |
2130 | #elif defined(SECOND) |
2131 | struct S6 { |
2132 | static const int y = 1; |
2133 | }; |
2134 | #else |
2135 | S6 s6; |
2136 | // expected-error@first.h:* {{'VarDecl::S6::x' from module 'FirstModule' is not present in definition of 'VarDecl::S6' in module 'SecondModule'}} |
2137 | // expected-note@second.h:* {{definition has no member 'x'}} |
2138 | #endif |
2139 | |
2140 | #if defined(FIRST) |
2141 | struct S7 { |
2142 | static const int x = 1; |
2143 | }; |
2144 | #elif defined(SECOND) |
2145 | struct S7 { |
2146 | static const unsigned x = 1; |
2147 | }; |
2148 | #else |
2149 | S7 s7; |
2150 | // expected-error@first.h:* {{'VarDecl::S7::x' from module 'FirstModule' is not present in definition of 'VarDecl::S7' in module 'SecondModule'}} |
2151 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2152 | #endif |
2153 | |
2154 | #if defined(FIRST) |
2155 | struct S8 { |
2156 | public: |
2157 | static const int x = 1; |
2158 | }; |
2159 | #elif defined(SECOND) |
2160 | struct S8 { |
2161 | static const int x = 1; |
2162 | public: |
2163 | }; |
2164 | #else |
2165 | S8 s8; |
2166 | // expected-error@second.h:* {{'VarDecl::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member}} |
2167 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
2168 | #endif |
2169 | |
2170 | #if defined(FIRST) |
2171 | struct S9 { |
2172 | static const int x = 1; |
2173 | }; |
2174 | #elif defined(SECOND) |
2175 | struct S9 { |
2176 | static int x; |
2177 | }; |
2178 | #else |
2179 | S9 s9; |
2180 | // expected-error@first.h:* {{'VarDecl::S9::x' from module 'FirstModule' is not present in definition of 'VarDecl::S9' in module 'SecondModule'}} |
2181 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2182 | #endif |
2183 | |
2184 | #define DECLS \ |
2185 | static int a; \ |
2186 | static I b; \ |
2187 | static const int c = 1; \ |
2188 | static constexpr int d = 5; |
2189 | |
2190 | #if defined(FIRST) || defined(SECOND) |
2191 | using I = int; |
2192 | #endif |
2193 | |
2194 | #if defined(FIRST) || defined(SECOND) |
2195 | struct Valid1 { |
2196 | DECLS |
2197 | }; |
2198 | #else |
2199 | Valid1 v1; |
2200 | #endif |
2201 | |
2202 | #if defined(FIRST) || defined(SECOND) |
2203 | struct Invalid1 { |
2204 | DECLS |
2205 | ACCESS |
2206 | }; |
2207 | #else |
2208 | Invalid1 i1; |
2209 | // expected-error@second.h:* {{'VarDecl::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
2210 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
2211 | #endif |
2212 | #undef DECLS |
2213 | } // namespace VarDecl |
2214 | |
2215 | namespace Friend { |
2216 | #if defined(FIRST) |
2217 | struct T1 {}; |
2218 | struct S1 { |
2219 | friend class T1; |
2220 | }; |
2221 | #elif defined(SECOND) |
2222 | struct T1 {}; |
2223 | struct S1 { |
2224 | friend T1; |
2225 | }; |
2226 | #else |
2227 | S1 s1; |
2228 | // expected-error@second.h:* {{'Friend::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'Friend::T1'}} |
2229 | // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T1'}} |
2230 | #endif |
2231 | |
2232 | #if defined(FIRST) |
2233 | struct T2 {}; |
2234 | struct S2 { |
2235 | friend class T2; |
2236 | }; |
2237 | #elif defined(SECOND) |
2238 | struct T2 {}; |
2239 | struct S2 { |
2240 | friend struct T2; |
2241 | }; |
2242 | #else |
2243 | S2 s2; |
2244 | // expected-error@second.h:* {{'Friend::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'struct T2'}} |
2245 | // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T2'}} |
2246 | #endif |
2247 | |
2248 | #if defined(FIRST) |
2249 | struct T4 {}; |
2250 | struct S4 { |
2251 | friend T4; |
2252 | }; |
2253 | #elif defined(SECOND) |
2254 | struct S4 { |
2255 | friend void T4(); |
2256 | }; |
2257 | #else |
2258 | S4 s4; |
2259 | // expected-error@second.h:* {{'Friend::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function}} |
2260 | // expected-note@first.h:* {{but in 'FirstModule' found friend class}} |
2261 | #endif |
2262 | |
2263 | #if defined(FIRST) |
2264 | struct S5 { |
2265 | friend void T5a(); |
2266 | }; |
2267 | #elif defined(SECOND) |
2268 | struct S5 { |
2269 | friend void T5b(); |
2270 | }; |
2271 | #else |
2272 | S5 s5; |
2273 | // expected-error@second.h:* {{'Friend::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function 'T5b'}} |
2274 | // expected-note@first.h:* {{but in 'FirstModule' found friend function 'T5a'}} |
2275 | #endif |
2276 | |
2277 | #define DECLS \ |
2278 | friend class FriendA; \ |
2279 | friend struct FriendB; \ |
2280 | friend FriendC; \ |
2281 | friend void Function(); |
2282 | |
2283 | #if defined(FIRST) || defined(SECOND) |
2284 | class FriendA {}; |
2285 | class FriendB {}; |
2286 | class FriendC {}; |
2287 | #endif |
2288 | |
2289 | #if defined(FIRST) || defined(SECOND) |
2290 | struct Valid1 { |
2291 | DECLS |
2292 | }; |
2293 | #else |
2294 | Valid1 v1; |
2295 | #endif |
2296 | |
2297 | #if defined(FIRST) || defined(SECOND) |
2298 | struct Invalid1 { |
2299 | DECLS |
2300 | ACCESS |
2301 | }; |
2302 | #else |
2303 | Invalid1 i1; |
2304 | // expected-error@second.h:* {{'Friend::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
2305 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
2306 | #endif |
2307 | #undef DECLS |
2308 | } // namespace Friend |
2309 | |
2310 | namespace TemplateParameters { |
2311 | #if defined(FIRST) |
2312 | template <class A> |
2313 | struct S1 {}; |
2314 | #elif defined(SECOND) |
2315 | template <class B> |
2316 | struct S1 {}; |
2317 | #else |
2318 | using TemplateParameters::S1; |
2319 | // expected-error@second.h:* {{'TemplateParameters::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter 'B'}} |
2320 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}} |
2321 | #endif |
2322 | |
2323 | #if defined(FIRST) |
2324 | template <class A = double> |
2325 | struct S2 {}; |
2326 | #elif defined(SECOND) |
2327 | template <class A = int> |
2328 | struct S2 {}; |
2329 | #else |
2330 | using TemplateParameters::S2; |
2331 | // 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}} |
2332 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}} |
2333 | #endif |
2334 | |
2335 | #if defined(FIRST) |
2336 | template <class A = int> |
2337 | struct S3 {}; |
2338 | #elif defined(SECOND) |
2339 | template <class A> |
2340 | struct S3 {}; |
2341 | #else |
2342 | using TemplateParameters::S3; |
2343 | // 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}} |
2344 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with default argument}} |
2345 | #endif |
2346 | |
2347 | #if defined(FIRST) |
2348 | template <int A> |
2349 | struct S4 {}; |
2350 | #elif defined(SECOND) |
2351 | template <int A = 2> |
2352 | struct S4 {}; |
2353 | #else |
2354 | using TemplateParameters::S4; |
2355 | // 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}} |
2356 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with no default argument}} |
2357 | #endif |
2358 | |
2359 | #if defined(FIRST) |
2360 | template <int> class S5_first {}; |
2361 | template <template<int> class A = S5_first> |
2362 | struct S5 {}; |
2363 | #elif defined(SECOND) |
2364 | template <int> class S5_second {}; |
2365 | template <template<int> class A = S5_second> |
2366 | struct S5 {}; |
2367 | #else |
2368 | using TemplateParameters::S5; |
2369 | // 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}} |
2370 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}} |
2371 | #endif |
2372 | |
2373 | #if defined(FIRST) |
2374 | template <class A> |
2375 | struct S6 {}; |
2376 | #elif defined(SECOND) |
2377 | template <class> |
2378 | struct S6 {}; |
2379 | #else |
2380 | using TemplateParameters::S6; |
2381 | // expected-error@second.h:* {{'TemplateParameters::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found unnamed template parameter}} |
2382 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}} |
2383 | #endif |
2384 | |
2385 | #define DECLS |
2386 | |
2387 | #if defined(FIRST) || defined(SECOND) |
2388 | template <class> class DefaultArg; |
2389 | #endif |
2390 | |
2391 | #if defined(FIRST) || defined(SECOND) |
2392 | template <int, class, template <class> class, |
2393 | int A, class B, template <int> class C, |
2394 | int D = 1, class E = int, template <class F> class = DefaultArg> |
2395 | struct Valid1 { |
2396 | DECLS |
2397 | }; |
2398 | #else |
2399 | using TemplateParameters::Valid1; |
2400 | #endif |
2401 | |
2402 | #if defined(FIRST) || defined(SECOND) |
2403 | template <int, class, template <class> class, |
2404 | int A, class B, template <int> class C, |
2405 | int D = 1, class E = int, template <class F> class = DefaultArg> |
2406 | struct Invalid1 { |
2407 | DECLS |
2408 | ACCESS |
2409 | }; |
2410 | #else |
2411 | using TemplateParameters::Invalid1; |
2412 | // expected-error@second.h:* {{'TemplateParameters::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
2413 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
2414 | #endif |
2415 | #undef DECLS |
2416 | } // namespace TemplateParameters |
2417 | |
2418 | namespace BaseClass { |
2419 | #if defined(FIRST) |
2420 | struct B1 {}; |
2421 | struct S1 : B1 {}; |
2422 | #elif defined(SECOND) |
2423 | struct S1 {}; |
2424 | #else |
2425 | S1 s1; |
2426 | // expected-error@second.h:* {{'BaseClass::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 base classes}} |
2427 | // expected-note@first.h:* {{but in 'FirstModule' found 1 base class}} |
2428 | #endif |
2429 | |
2430 | #if defined(FIRST) |
2431 | struct S2 {}; |
2432 | #elif defined(SECOND) |
2433 | struct B2 {}; |
2434 | struct S2 : virtual B2 {}; |
2435 | #else |
2436 | S2 s2; |
2437 | // expected-error@second.h:* {{'BaseClass::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 base class}} |
2438 | // expected-note@first.h:* {{but in 'FirstModule' found 0 base classes}} |
2439 | #endif |
2440 | |
2441 | #if defined(FIRST) |
2442 | struct B3a {}; |
2443 | struct S3 : B3a {}; |
2444 | #elif defined(SECOND) |
2445 | struct B3b {}; |
2446 | struct S3 : virtual B3b {}; |
2447 | #else |
2448 | S3 s3; |
2449 | // expected-error@second.h:* {{'BaseClass::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}} |
2450 | // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}} |
2451 | #endif |
2452 | |
2453 | #if defined(FIRST) |
2454 | struct B4a {}; |
2455 | struct S4 : B4a {}; |
2456 | #elif defined(SECOND) |
2457 | struct B4b {}; |
2458 | struct S4 : B4b {}; |
2459 | #else |
2460 | S4 s4; |
2461 | // expected-error@second.h:* {{'BaseClass::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class with type 'BaseClass::B4b'}} |
2462 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class with different type 'BaseClass::B4a'}} |
2463 | #endif |
2464 | |
2465 | #if defined(FIRST) |
2466 | struct B5a {}; |
2467 | struct S5 : virtual B5a {}; |
2468 | #elif defined(SECOND) |
2469 | struct B5a {}; |
2470 | struct S5 : B5a {}; |
2471 | #else |
2472 | S5 s5; |
2473 | // expected-error@second.h:* {{'BaseClass::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 virtual base classes}} |
2474 | // expected-note@first.h:* {{but in 'FirstModule' found 1 virtual base class}} |
2475 | #endif |
2476 | |
2477 | #if defined(FIRST) |
2478 | struct B6a {}; |
2479 | struct S6 : B6a {}; |
2480 | #elif defined(SECOND) |
2481 | struct B6a {}; |
2482 | struct S6 : virtual B6a {}; |
2483 | #else |
2484 | S6 s6; |
2485 | // expected-error@second.h:* {{'BaseClass::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}} |
2486 | // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}} |
2487 | #endif |
2488 | |
2489 | #if defined(FIRST) |
2490 | struct B7a {}; |
2491 | struct S7 : protected B7a {}; |
2492 | #elif defined(SECOND) |
2493 | struct B7a {}; |
2494 | struct S7 : B7a {}; |
2495 | #else |
2496 | S7 s7; |
2497 | // expected-error@second.h:* {{'BaseClass::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B7a' with no access specifier}} |
2498 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B7a' with protected access specifier}} |
2499 | #endif |
2500 | |
2501 | #if defined(FIRST) |
2502 | struct B8a {}; |
2503 | struct S8 : public B8a {}; |
2504 | #elif defined(SECOND) |
2505 | struct B8a {}; |
2506 | struct S8 : private B8a {}; |
2507 | #else |
2508 | S8 s8; |
2509 | // expected-error@second.h:* {{'BaseClass::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B8a' with private access specifier}} |
2510 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B8a' with public access specifier}} |
2511 | #endif |
2512 | |
2513 | #if defined(FIRST) |
2514 | struct B9a {}; |
2515 | struct S9 : private B9a {}; |
2516 | #elif defined(SECOND) |
2517 | struct B9a {}; |
2518 | struct S9 : public B9a {}; |
2519 | #else |
2520 | S9 s9; |
2521 | // expected-error@second.h:* {{'BaseClass::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B9a' with public access specifier}} |
2522 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B9a' with private access specifier}} |
2523 | #endif |
2524 | |
2525 | #if defined(FIRST) |
2526 | struct B10a {}; |
2527 | struct S10 : B10a {}; |
2528 | #elif defined(SECOND) |
2529 | struct B10a {}; |
2530 | struct S10 : protected B10a {}; |
2531 | #else |
2532 | S10 s10; |
2533 | // expected-error@second.h:* {{'BaseClass::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B10a' with protected access specifier}} |
2534 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B10a' with no access specifier}} |
2535 | #endif |
2536 | |
2537 | #define DECLS |
2538 | |
2539 | #if defined(FIRST) || defined(SECOND) |
2540 | struct Base1 {}; |
2541 | struct Base2 {}; |
2542 | struct Base3 {}; |
2543 | struct Base4 {}; |
2544 | struct Base5 {}; |
2545 | #endif |
2546 | |
2547 | #if defined(FIRST) || defined(SECOND) |
2548 | struct Valid1 : |
2549 | Base1, virtual Base2, protected Base3, public Base4, private Base5 { |
2550 | |
2551 | DECLS |
2552 | }; |
2553 | #else |
2554 | Valid1 v1; |
2555 | #endif |
2556 | |
2557 | #if defined(FIRST) || defined(SECOND) |
2558 | struct Invalid1 : |
2559 | Base1, virtual Base2, protected Base3, public Base4, private Base5 { |
2560 | |
2561 | DECLS |
2562 | ACCESS |
2563 | }; |
2564 | #else |
2565 | Invalid1 i1; |
2566 | // expected-error@second.h:* {{'BaseClass::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
2567 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
2568 | #endif |
2569 | #undef DECLS |
2570 | } // namespace BaseClass |
2571 | |
2572 | namespace PointersAndReferences { |
2573 | #if defined(FIRST) || defined(SECOND) |
2574 | template<typename> struct Wrapper{}; |
2575 | #endif |
2576 | |
2577 | #if defined(FIRST) |
2578 | struct S1 { |
2579 | Wrapper<int*> x; |
2580 | }; |
2581 | #elif defined(SECOND) |
2582 | struct S1 { |
2583 | Wrapper<float*> x; |
2584 | }; |
2585 | #else |
2586 | S1 s1; |
2587 | // expected-error@first.h:* {{PointersAndReferences::S1::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S1' in module 'SecondModule'}} |
2588 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2589 | #endif |
2590 | |
2591 | #if defined(FIRST) |
2592 | struct S2 { |
2593 | Wrapper<int &&> x; |
2594 | }; |
2595 | #elif defined(SECOND) |
2596 | struct S2 { |
2597 | Wrapper<float &&> x; |
2598 | }; |
2599 | #else |
2600 | S2 s2; |
2601 | // expected-error@first.h:* {{PointersAndReferences::S2::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S2' in module 'SecondModule'}} |
2602 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2603 | #endif |
2604 | |
2605 | #if defined(FIRST) |
2606 | struct S3 { |
2607 | Wrapper<int *> x; |
2608 | }; |
2609 | #elif defined(SECOND) |
2610 | struct S3 { |
2611 | Wrapper<float *> x; |
2612 | }; |
2613 | #else |
2614 | S3 s3; |
2615 | // expected-error@first.h:* {{PointersAndReferences::S3::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S3' in module 'SecondModule'}} |
2616 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2617 | #endif |
2618 | |
2619 | #if defined(FIRST) |
2620 | struct S4 { |
2621 | Wrapper<int &> x; |
2622 | }; |
2623 | #elif defined(SECOND) |
2624 | struct S4 { |
2625 | Wrapper<float &> x; |
2626 | }; |
2627 | #else |
2628 | S4 s4; |
2629 | // expected-error@first.h:* {{PointersAndReferences::S4::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S4' in module 'SecondModule'}} |
2630 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2631 | #endif |
2632 | |
2633 | #if defined(FIRST) |
2634 | struct S5 { |
2635 | Wrapper<S5 *> x; |
2636 | }; |
2637 | #elif defined(SECOND) |
2638 | struct S5 { |
2639 | Wrapper<const S5 *> x; |
2640 | }; |
2641 | #else |
2642 | S5 s5; |
2643 | // expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 'SecondModule' is not present in definition of 'PointersAndReferences::S5' in module 'FirstModule'}} |
2644 | // expected-note@first.h:* {{declaration of 'x' does not match}} |
2645 | #endif |
2646 | |
2647 | #if defined(FIRST) |
2648 | struct S6 { |
2649 | Wrapper<int &> x; |
2650 | }; |
2651 | #elif defined(SECOND) |
2652 | struct S6 { |
2653 | Wrapper<const int &> x; |
2654 | }; |
2655 | #else |
2656 | S6 s6; |
2657 | // expected-error@first.h:* {{PointersAndReferences::S6::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S6' in module 'SecondModule'}} |
2658 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
2659 | #endif |
2660 | |
2661 | #define DECLS \ |
2662 | Wrapper<int *> x1; \ |
2663 | Wrapper<float *> x2; \ |
2664 | Wrapper<const float *> x3; \ |
2665 | Wrapper<int &> x4; \ |
2666 | Wrapper<int &&> x5; \ |
2667 | Wrapper<const int &> x6; \ |
2668 | Wrapper<S1 *> x7; \ |
2669 | Wrapper<S1 &> x8; \ |
2670 | Wrapper<S1 &&> x9; |
2671 | |
2672 | #if defined(FIRST) || defined(SECOND) |
2673 | struct Valid1 { |
2674 | DECLS |
2675 | }; |
2676 | #else |
2677 | Valid1 v1; |
2678 | #endif |
2679 | |
2680 | #if defined(FIRST) || defined(SECOND) |
2681 | struct Invalid1 { |
2682 | DECLS |
2683 | ACCESS |
2684 | }; |
2685 | #else |
2686 | Invalid1 i1; |
2687 | // expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
2688 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
2689 | #endif |
2690 | #undef DECLS |
2691 | } // namespace PointersAndReferences |
2692 | |
2693 | namespace FunctionTemplate { |
2694 | #if defined(FIRST) |
2695 | struct S1 { |
2696 | template <int, int> void foo(); |
2697 | }; |
2698 | #elif defined(SECOND) |
2699 | struct S1 { |
2700 | template <int> void foo(); |
2701 | }; |
2702 | #else |
2703 | S1 s1; |
2704 | // expected-error@first.h:* {{'FunctionTemplate::S1::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S1' in module 'SecondModule'}} |
2705 | // expected-note@second.h:* {{declaration of 'foo' does not match}} |
2706 | #endif |
2707 | |
2708 | #if defined(FIRST) |
2709 | struct S2 { |
2710 | template <char> void foo(); |
2711 | }; |
2712 | #elif defined(SECOND) |
2713 | struct S2 { |
2714 | template <int> void foo(); |
2715 | }; |
2716 | #else |
2717 | S2 s2; |
2718 | // expected-error@first.h:* {{'FunctionTemplate::S2::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S2' in module 'SecondModule'}} |
2719 | // expected-note@second.h:* {{declaration of 'foo' does not match}} |
2720 | #endif |
2721 | |
2722 | #if defined(FIRST) |
2723 | struct S3 { |
2724 | template <int x> void foo(); |
2725 | }; |
2726 | #elif defined(SECOND) |
2727 | struct S3 { |
2728 | template <int y> void foo(); |
2729 | }; |
2730 | #else |
2731 | S3 s3; |
2732 | // 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'}} |
2733 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}} |
2734 | #endif |
2735 | |
2736 | #if defined(FIRST) |
2737 | struct S4 { |
2738 | template <int x> void foo(); |
2739 | }; |
2740 | #elif defined(SECOND) |
2741 | struct S4 { |
2742 | template <int x> void bar(); |
2743 | }; |
2744 | #else |
2745 | S4 s4; |
2746 | // expected-error@first.h:* {{'FunctionTemplate::S4::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S4' in module 'SecondModule'}} |
2747 | // expected-note@second.h:* {{definition has no member 'foo'}} |
2748 | #endif |
2749 | |
2750 | #if defined(FIRST) |
2751 | struct S5 { |
2752 | template <int x> void foo(); |
2753 | }; |
2754 | #elif defined(SECOND) |
2755 | struct S5 { |
2756 | public: |
2757 | template <int x> void foo(); |
2758 | }; |
2759 | #else |
2760 | S5 s5; |
2761 | // expected-error@second.h:* {{'FunctionTemplate::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
2762 | // expected-note@first.h:* {{but in 'FirstModule' found function template}} |
2763 | #endif |
2764 | |
2765 | #if defined(FIRST) |
2766 | struct S6 { |
2767 | template <typename x = int> void foo(); |
2768 | }; |
2769 | #elif defined(SECOND) |
2770 | struct S6 { |
2771 | template <typename x> void foo(); |
2772 | }; |
2773 | #else |
2774 | S6 s6; |
2775 | // 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}} |
2776 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}} |
2777 | #endif |
2778 | |
2779 | #if defined(FIRST) |
2780 | struct S7 { |
2781 | template <typename x = void> void foo(); |
2782 | }; |
2783 | #elif defined(SECOND) |
2784 | struct S7 { |
2785 | template <typename x = int> void foo(); |
2786 | }; |
2787 | #else |
2788 | S7 s7; |
2789 | // 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'}} |
2790 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'void'}} |
2791 | #endif |
2792 | |
2793 | #if defined(FIRST) |
2794 | template <int> |
2795 | struct U8 {}; |
2796 | struct S8 { |
2797 | template <template<int> class x = U8> void foo(); |
2798 | }; |
2799 | #elif defined(SECOND) |
2800 | template <int> |
2801 | struct T8 {}; |
2802 | struct S8{ |
2803 | template <template<int> class x = T8> void foo(); |
2804 | }; |
2805 | #else |
2806 | S8 s8; |
2807 | // 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'}} |
2808 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'U8'}} |
2809 | #endif |
2810 | |
2811 | #if defined(FIRST) |
2812 | template <int> |
2813 | struct U9 {}; |
2814 | struct S9 { S9(); |
2815 | template <template<int> class x = U9> void foo(); |
2816 | }; |
2817 | #elif defined(SECOND) |
2818 | struct S9 { S9(); |
2819 | template <template<int> class x> void foo(); |
2820 | }; |
2821 | #else |
2822 | S9 s9; |
2823 | // 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}} |
2824 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}} |
2825 | #endif |
2826 | |
2827 | #if defined(FIRST) |
2828 | struct S10 { |
2829 | template <template<int> class x> void foo(); |
2830 | template <template<typename> class x> void foo(); |
2831 | }; |
2832 | #elif defined(SECOND) |
2833 | struct S10 { |
2834 | template <template<typename> class x> void foo(); |
2835 | template <template<int> class x> void foo(); |
2836 | }; |
2837 | #else |
2838 | S10 s10; |
2839 | // 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}} |
2840 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}} |
2841 | #endif |
2842 | |
2843 | #if defined(FIRST) |
2844 | struct S11 { |
2845 | template <template<int> class x> void foo(); |
2846 | }; |
2847 | #elif defined(SECOND) |
2848 | struct S11 { |
2849 | template <template<int> class> void foo(); |
2850 | }; |
2851 | #else |
2852 | S11 s11; |
2853 | // 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}} |
2854 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}} |
2855 | #endif |
2856 | |
2857 | #if defined(FIRST) |
2858 | struct S12 { |
2859 | template <class> void foo(); |
2860 | template <class, class> void foo(); |
2861 | }; |
2862 | #elif defined(SECOND) |
2863 | struct S12 { |
2864 | template <class, class> void foo(); |
2865 | template <class> void foo(); |
2866 | }; |
2867 | #else |
2868 | S12 s12; |
2869 | // 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}} |
2870 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1 template parameter}} |
2871 | #endif |
2872 | |
2873 | #if defined(FIRST) |
2874 | struct S13 { |
2875 | template <class = int> void foo(); |
2876 | }; |
2877 | #elif defined(SECOND) |
2878 | struct S13 { |
2879 | template <class = void> void foo(); |
2880 | }; |
2881 | #else |
2882 | S13 s13; |
2883 | // 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'}} |
2884 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'int'}} |
2885 | #endif |
2886 | |
2887 | #if defined(FIRST) |
2888 | struct S14 { |
2889 | template <class = void> void foo(); |
2890 | }; |
2891 | #elif defined(SECOND) |
2892 | struct S14 { |
2893 | template <class> void foo(); |
2894 | }; |
2895 | #else |
2896 | S14 s14; |
2897 | // 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}} |
2898 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}} |
2899 | #endif |
2900 | |
2901 | #if defined(FIRST) |
2902 | struct S15 { |
2903 | template <class> void foo(); |
2904 | }; |
2905 | #elif defined(SECOND) |
2906 | struct S15 { |
2907 | template <class = void> void foo(); |
2908 | }; |
2909 | #else |
2910 | S15 s15; |
2911 | // 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}} |
2912 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}} |
2913 | #endif |
2914 | |
2915 | #if defined(FIRST) |
2916 | struct S16 { |
2917 | template <short> void foo(); |
2918 | }; |
2919 | #elif defined(SECOND) |
2920 | struct S16 { |
2921 | template <short = 1> void foo(); |
2922 | }; |
2923 | #else |
2924 | S16 s16; |
2925 | // 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}} |
2926 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}} |
2927 | #endif |
2928 | |
2929 | #if defined(FIRST) |
2930 | struct S17 { |
2931 | template <short = 2> void foo(); |
2932 | }; |
2933 | #elif defined(SECOND) |
2934 | struct S17 { |
2935 | template <short = 1 + 1> void foo(); |
2936 | }; |
2937 | #else |
2938 | S17 s17; |
2939 | // 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}} |
2940 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 2}} |
2941 | #endif |
2942 | |
2943 | #if defined(FIRST) |
2944 | struct S18 { |
2945 | template <short> void foo(); |
2946 | template <int> void foo(); |
2947 | }; |
2948 | #elif defined(SECOND) |
2949 | struct S18 { |
2950 | template <int> void foo(); |
2951 | template <short> void foo(); |
2952 | }; |
2953 | #else |
2954 | S18 s18; |
2955 | // 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}} |
2956 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}} |
2957 | #endif |
2958 | |
2959 | #if defined(FIRST) |
2960 | struct S19 { |
2961 | template <short> void foo(); |
2962 | template <short...> void foo(); |
2963 | }; |
2964 | #elif defined(SECOND) |
2965 | struct S19 { |
2966 | template <short...> void foo(); |
2967 | template <short> void foo(); |
2968 | }; |
2969 | #else |
2970 | S19 s19; |
2971 | // 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}} |
2972 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}} |
2973 | #endif |
2974 | |
2975 | #if defined(FIRST) |
2976 | struct S20 { |
2977 | template <class> void foo(); |
2978 | template <class...> void foo(); |
2979 | }; |
2980 | #elif defined(SECOND) |
2981 | struct S20 { |
2982 | template <class...> void foo(); |
2983 | template <class> void foo(); |
2984 | }; |
2985 | #else |
2986 | S20 s20; |
2987 | // 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}} |
2988 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}} |
2989 | #endif |
2990 | |
2991 | #if defined(FIRST) |
2992 | struct S21 { |
2993 | template <template<class> class...> void foo(); |
2994 | template <template<class> class> void foo(); |
2995 | }; |
2996 | #elif defined(SECOND) |
2997 | struct S21 { |
2998 | template <template<class> class> void foo(); |
2999 | template <template<class> class...> void foo(); |
3000 | }; |
3001 | #else |
3002 | S21 s21; |
3003 | // 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}} |
3004 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter being a template parameter pack}} |
3005 | #endif |
3006 | |
3007 | #if defined(FIRST) |
3008 | struct S22 { |
3009 | template <template<class> class> void foo(); |
3010 | template <class> void foo(); |
3011 | template <int> void foo(); |
3012 | }; |
3013 | #elif defined(SECOND) |
3014 | struct S22 { |
3015 | template <class> void foo(); |
3016 | template <int> void foo(); |
3017 | template <template<class> class> void foo(); |
3018 | }; |
3019 | #else |
3020 | S22 s22; |
3021 | // 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}} |
3022 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a template template parameter}} |
3023 | #endif |
3024 | |
3025 | #if defined(FIRST) |
3026 | struct S23 { |
3027 | template <class> void foo(); |
3028 | template <int> void foo(); |
3029 | template <template<class> class> void foo(); |
3030 | }; |
3031 | #elif defined(SECOND) |
3032 | struct S23 { |
3033 | template <int> void foo(); |
3034 | template <template<class> class> void foo(); |
3035 | template <class> void foo(); |
3036 | }; |
3037 | #else |
3038 | S23 s23; |
3039 | // 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}} |
3040 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a type template parameter}} |
3041 | #endif |
3042 | |
3043 | #if defined(FIRST) |
3044 | struct S24 { |
3045 | template <int> void foo(); |
3046 | template <template<class> class> void foo(); |
3047 | template <class> void foo(); |
3048 | }; |
3049 | #elif defined(SECOND) |
3050 | struct S24 { |
3051 | template <template<class> class> void foo(); |
3052 | template <class> void foo(); |
3053 | template <int> void foo(); |
3054 | }; |
3055 | #else |
3056 | S24 s24; |
3057 | // 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}} |
3058 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a non-type template parameter}} |
3059 | #endif |
3060 | |
3061 | #if defined(FIRST) |
3062 | struct S25 { |
3063 | template <int> void foo(); |
3064 | }; |
3065 | #elif defined(SECOND) |
3066 | struct S25 { |
3067 | public: |
3068 | template <int> void foo(); |
3069 | }; |
3070 | #else |
3071 | S25 s25; |
3072 | // expected-error@second.h:* {{'FunctionTemplate::S25' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
3073 | // expected-note@first.h:* {{but in 'FirstModule' found function template}} |
3074 | #endif |
3075 | |
3076 | #define DECLS \ |
3077 | template <int> \ |
3078 | void nontype1(); \ |
3079 | template <int x> \ |
3080 | void nontype2(); \ |
3081 | template <int, int> \ |
3082 | void nontype3(); \ |
3083 | template <int x = 5> \ |
3084 | void nontype4(); \ |
3085 | template <int... x> \ |
3086 | void nontype5(); \ |
3087 | \ |
3088 | template <class> \ |
3089 | void type1(); \ |
3090 | template <class x> \ |
3091 | void type2(); \ |
3092 | template <class, class> \ |
3093 | void type3(); \ |
3094 | template <class x = int> \ |
3095 | void type4(); \ |
3096 | template <class... x> \ |
3097 | void type5(); \ |
3098 | \ |
3099 | template <template <int> class> \ |
3100 | void template1(); \ |
3101 | template <template <int> class x> \ |
3102 | void template2(); \ |
3103 | template <template <int> class, template <int> class> \ |
3104 | void template3(); \ |
3105 | template <template <int> class x = U> \ |
3106 | void template4(); \ |
3107 | template <template <int> class... x> \ |
3108 | void template5(); |
3109 | |
3110 | #if defined(FIRST) || defined(SECOND) |
3111 | template<int> |
3112 | struct U {}; |
3113 | struct Valid1 { |
3114 | DECLS |
3115 | }; |
3116 | #else |
3117 | Valid1 v1; |
3118 | #endif |
3119 | |
3120 | #if defined(FIRST) || defined(SECOND) |
3121 | struct Invalid1 { |
3122 | DECLS |
3123 | ACCESS |
3124 | }; |
3125 | #else |
3126 | Invalid1 i1; |
3127 | // expected-error@second.h:* {{'FunctionTemplate::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
3128 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
3129 | #endif |
3130 | #undef DECLS |
3131 | } |
3132 | |
3133 | namespace Enums { |
3134 | #if defined(FIRST) |
3135 | enum E1 { x11 }; |
3136 | #elif defined(SECOND) |
3137 | enum E1 {}; |
3138 | #else |
3139 | E1 e1; |
3140 | // expected-error@first.h:* {{'Enums::x11' from module 'FirstModule' is not present in definition of 'Enums::E1' in module 'SecondModule'}} |
3141 | // expected-note@second.h:* {{definition has no member 'x11'}} |
3142 | #endif |
3143 | |
3144 | #if defined(FIRST) |
3145 | enum E2 {}; |
3146 | #elif defined(SECOND) |
3147 | enum E2 { x21 }; |
3148 | #else |
3149 | E2 e2; |
3150 | // expected-error@second.h:* {{'Enums::E2' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 1 element}} |
3151 | // expected-note@first.h:* {{but in 'FirstModule' found enum with 0 elements}} |
3152 | #endif |
3153 | |
3154 | #if defined(FIRST) |
3155 | enum E3 { x31 }; |
3156 | #elif defined(SECOND) |
3157 | enum E3 { x32 }; |
3158 | #else |
3159 | E3 e3; |
3160 | // expected-error@first.h:* {{'Enums::x31' from module 'FirstModule' is not present in definition of 'Enums::E3' in module 'SecondModule'}} |
3161 | // expected-note@second.h:* {{definition has no member 'x31'}} |
3162 | #endif |
3163 | |
3164 | #if defined(FIRST) |
3165 | enum E4 { x41 }; |
3166 | #elif defined(SECOND) |
3167 | enum E4 { x41, x42 }; |
3168 | #else |
3169 | E4 e4; |
3170 | // expected-error@second.h:* {{'Enums::E4' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with 2 elements}} |
3171 | // expected-note@first.h:* {{but in 'FirstModule' found enum with 1 element}} |
3172 | #endif |
3173 | |
3174 | #if defined(FIRST) |
3175 | enum E5 { x51, x52 }; |
3176 | #elif defined(SECOND) |
3177 | enum E5 { x51 }; |
3178 | #else |
3179 | E5 e5; |
3180 | // expected-error@first.h:* {{'Enums::x52' from module 'FirstModule' is not present in definition of 'Enums::E5' in module 'SecondModule'}} |
3181 | // expected-note@second.h:* {{definition has no member 'x52'}} |
3182 | #endif |
3183 | |
3184 | #if defined(FIRST) |
3185 | enum E6 { x61, x62 }; |
3186 | #elif defined(SECOND) |
3187 | enum E6 { x62, x61 }; |
3188 | #else |
3189 | E6 e6; |
3190 | // expected-error@second.h:* {{'Enums::E6' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element has name 'x62'}} |
3191 | // expected-note@first.h:* {{but in 'FirstModule' found 1st element has name 'x61'}} |
3192 | #endif |
3193 | |
3194 | #if defined(FIRST) |
3195 | enum E7 { x71 = 0 }; |
3196 | #elif defined(SECOND) |
3197 | enum E7 { x71 }; |
3198 | #else |
3199 | E7 e7; |
3200 | // expected-error@second.h:* {{'Enums::E7' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element 'x71' has an initilizer}} |
3201 | // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x71' does not have an initializer}} |
3202 | #endif |
3203 | |
3204 | #if defined(FIRST) |
3205 | enum E8 { x81 }; |
3206 | #elif defined(SECOND) |
3207 | enum E8 { x81 = 0 }; |
3208 | #else |
3209 | E8 e8; |
3210 | // expected-error@second.h:* {{'Enums::E8' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st element 'x81' does not have an initilizer}} |
3211 | // expected-note@first.h:* {{but in 'FirstModule' found 1st element 'x81' has an initializer}} |
3212 | #endif |
3213 | |
3214 | #if defined(FIRST) |
3215 | enum E9 { x91 = 0, x92 = 1 }; |
3216 | #elif defined(SECOND) |
3217 | enum E9 { x91 = 0, x92 = 2 - 1 }; |
3218 | #else |
3219 | E9 e9; |
3220 | // 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}} |
3221 | // expected-note@first.h:* {{but in 'FirstModule' found 2nd element 'x92' has different initializer}} |
3222 | #endif |
3223 | |
3224 | #if defined(FIRST) |
3225 | enum class E10 : int {}; |
3226 | #elif defined(SECOND) |
3227 | enum class E10 {}; |
3228 | #else |
3229 | E10 e10; |
3230 | // expected-error@second.h:* {{'Enums::E10' has different definitions in different modules; definition in module 'SecondModule' first difference is enum without specified type}} |
3231 | // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type}} |
3232 | #endif |
3233 | |
3234 | #if defined(FIRST) |
3235 | enum E11 {}; |
3236 | #elif defined(SECOND) |
3237 | enum E11 : int {}; |
3238 | #else |
3239 | E11 e11; |
3240 | // expected-error@second.h:* {{'Enums::E11' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type}} |
3241 | // expected-note@first.h:* {{but in 'FirstModule' found enum without specified type}} |
3242 | #endif |
3243 | |
3244 | #if defined(FIRST) |
3245 | enum struct E12 : long {}; |
3246 | #elif defined(SECOND) |
3247 | enum struct E12 : int {}; |
3248 | #else |
3249 | E12 e12; |
3250 | // expected-error@second.h:* {{'Enums::E12' has different definitions in different modules; definition in module 'SecondModule' first difference is enum with specified type 'int'}} |
3251 | // expected-note@first.h:* {{but in 'FirstModule' found enum with specified type 'long'}} |
3252 | #endif |
3253 | |
3254 | #if defined(FIRST) |
3255 | enum struct E13 {}; |
3256 | #elif defined(SECOND) |
3257 | enum E13 {}; |
3258 | #else |
3259 | E13 e13; |
3260 | // expected-error@second.h:* {{'Enums::E13' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is not scoped}} |
3261 | // expected-note@first.h:* {{but in 'FirstModule' found enum that is scoped}} |
3262 | #endif |
3263 | |
3264 | #if defined(FIRST) |
3265 | enum E14 {}; |
3266 | #elif defined(SECOND) |
3267 | enum struct E14 {}; |
3268 | #else |
3269 | E14 e14; |
3270 | // expected-error@second.h:* {{'Enums::E14' has different definitions in different modules; definition in module 'SecondModule' first difference is enum that is scoped}} |
3271 | // expected-note@first.h:* {{but in 'FirstModule' found enum that is not scoped}} |
3272 | #endif |
3273 | |
3274 | #if defined(FIRST) |
3275 | enum class E15 {}; |
3276 | #elif defined(SECOND) |
3277 | enum struct E15 {}; |
3278 | #else |
3279 | E15 e15; |
3280 | // expected-error@second.h:* {{'Enums::E15' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword struct}} |
3281 | // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword class}} |
3282 | #endif |
3283 | |
3284 | #if defined(FIRST) |
3285 | enum struct E16 {}; |
3286 | #elif defined(SECOND) |
3287 | enum class E16 {}; |
3288 | #else |
3289 | E16 e16; |
3290 | // expected-error@second.h:* {{'Enums::E16' has different definitions in different modules; definition in module 'SecondModule' first difference is enum scoped with keyword class}} |
3291 | // expected-note@first.h:* {{but in 'FirstModule' found enum scoped with keyword struct}} |
3292 | #endif |
3293 | |
3294 | #if defined(FIRST) |
3295 | enum Valid { v1 = (struct S*)0 == (struct S*)0 }; |
3296 | #elif defined(SECOND) |
3297 | struct S {}; |
3298 | enum Valid { v1 = (struct S*)0 == (struct S*)0 }; |
3299 | #else |
3300 | Valid V; |
3301 | #endif |
3302 | } // namespace Enums |
3303 | |
3304 | namespace Types { |
3305 | namespace Complex { |
3306 | #if defined(FIRST) |
3307 | void invalid() { |
3308 | _Complex float x; |
3309 | } |
3310 | void valid() { |
3311 | _Complex float x; |
3312 | } |
3313 | #elif defined(SECOND) |
3314 | void invalid() { |
3315 | _Complex double x; |
3316 | } |
3317 | void valid() { |
3318 | _Complex float x; |
3319 | } |
3320 | #else |
3321 | auto function1 = invalid; |
3322 | // expected-error@second.h:* {{'Types::Complex::invalid' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3323 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3324 | auto function2 = valid; |
3325 | #endif |
3326 | } // namespace Complex |
3327 | |
3328 | namespace Decltype { |
3329 | #if defined(FIRST) |
3330 | void invalid1() { |
3331 | decltype(1 + 1) x; |
3332 | } |
3333 | int global; |
3334 | void invalid2() { |
3335 | decltype(global) x; |
3336 | } |
3337 | void valid() { |
3338 | decltype(1.5) x; |
3339 | decltype(x) y; |
3340 | } |
3341 | #elif defined(SECOND) |
3342 | void invalid1() { |
3343 | decltype(2) x; |
3344 | } |
3345 | float global; |
3346 | void invalid2() { |
3347 | decltype(global) x; |
3348 | } |
3349 | void valid() { |
3350 | decltype(1.5) x; |
3351 | decltype(x) y; |
3352 | } |
3353 | #else |
3354 | auto function1 = invalid1; |
3355 | // expected-error@second.h:* {{'Types::Decltype::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3356 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3357 | auto function2 = invalid2; |
3358 | // expected-error@second.h:* {{'Types::Decltype::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3359 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3360 | auto function3 = valid; |
3361 | #endif |
3362 | } // namespace Decltype |
3363 | |
3364 | namespace Auto { |
3365 | #if defined(FIRST) |
3366 | void invalid1() { |
3367 | decltype(auto) x = 1; |
3368 | } |
3369 | void invalid2() { |
3370 | auto x = 1; |
3371 | } |
3372 | void invalid3() { |
3373 | __auto_type x = 1; |
3374 | } |
3375 | void valid() { |
3376 | decltype(auto) x = 1; |
3377 | auto y = 1; |
3378 | __auto_type z = 1; |
3379 | } |
3380 | #elif defined(SECOND) |
3381 | void invalid1() { |
3382 | auto x = 1; |
3383 | } |
3384 | void invalid2() { |
3385 | __auto_type x = 1; |
3386 | } |
3387 | void invalid3() { |
3388 | decltype(auto) x = 1; |
3389 | } |
3390 | void valid() { |
3391 | decltype(auto) x = 1; |
3392 | auto y = 1; |
3393 | __auto_type z = 1; |
3394 | } |
3395 | #else |
3396 | auto function1 = invalid1; |
3397 | // expected-error@second.h:* {{'Types::Auto::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3398 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3399 | auto function2 = invalid3; |
3400 | // expected-error@second.h:* {{'Types::Auto::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3401 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3402 | auto function3 = invalid2; |
3403 | // expected-error@second.h:* {{'Types::Auto::invalid3' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3404 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3405 | auto function4 = valid; |
3406 | #endif |
3407 | } // namespace Auto |
3408 | |
3409 | namespace DeducedTemplateSpecialization { |
3410 | #if defined(FIRST) |
3411 | template<typename T> struct A {}; |
3412 | A() -> A<int>; |
3413 | template<typename T> struct B {}; |
3414 | B() -> B<int>; |
3415 | |
3416 | void invalid1() { |
3417 | A a{}; |
3418 | } |
3419 | void invalid2() { |
3420 | A a{}; |
3421 | } |
3422 | void valid() { |
3423 | B b{}; |
3424 | } |
3425 | #elif defined(SECOND) |
3426 | template<typename T> struct A {}; |
3427 | A() -> A<float>; |
3428 | template<typename T> struct B {}; |
3429 | B() -> B<int>; |
3430 | |
3431 | void invalid1() { |
3432 | A a{}; |
3433 | } |
3434 | void invalid2() { |
3435 | B a{}; |
3436 | } |
3437 | void valid() { |
3438 | B b{}; |
3439 | } |
3440 | #else |
3441 | auto function1 = invalid1; |
3442 | // expected-error@second.h:* {{'Types::DeducedTemplateSpecialization::invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3443 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3444 | auto function2 = invalid2; |
3445 | // expected-error@second.h:* {{'Types::DeducedTemplateSpecialization::invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3446 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3447 | auto function3 = valid; |
3448 | #endif |
3449 | } // namespace DeducedTemplateSpecialization |
3450 | |
3451 | namespace DependentAddressSpace { |
3452 | #if defined(FIRST) |
3453 | template <int A1, int A2> |
3454 | void invalid1() { |
3455 | using type = int __attribute__((address_space(A1))); |
3456 | } |
3457 | template <int A1> |
3458 | void invalid2() { |
3459 | using type = float __attribute__((address_space(A1))); |
3460 | } |
3461 | template <int A1, int A2> |
3462 | void valid() { |
3463 | using type1 = float __attribute__((address_space(A1))); |
3464 | using type2 = int __attribute__((address_space(A2))); |
3465 | using type3 = int __attribute__((address_space(A1 + A2))); |
3466 | } |
3467 | #elif defined(SECOND) |
3468 | template <int A1, int A2> |
3469 | void invalid1() { |
3470 | using type = int __attribute__((address_space(A2))); |
3471 | } |
3472 | template <int A1> |
3473 | void invalid2() { |
3474 | using type = int __attribute__((address_space(A1))); |
3475 | } |
3476 | template <int A1, int A2> |
3477 | void valid() { |
3478 | using type1 = float __attribute__((address_space(A1))); |
3479 | using type2 = int __attribute__((address_space(A2))); |
3480 | using type3 = int __attribute__((address_space(A1 + A2))); |
3481 | } |
3482 | #else |
3483 | template <int A, int B> |
3484 | class S { |
3485 | static auto function1 = invalid1<A, B>; |
3486 | // expected-error@first.h:* {{'Types::DependentAddressSpace::invalid1' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}} |
3487 | // expected-note@second.h:* {{but in 'SecondModule' found a different body}} |
3488 | static auto function2 = invalid2<B>; |
3489 | // expected-error@first.h:* {{'Types::DependentAddressSpace::invalid2' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}} |
3490 | // expected-note@second.h:* {{but in 'SecondModule' found a different body}} |
3491 | static auto function3 = valid<A, B>; |
3492 | }; |
3493 | #endif |
3494 | } // namespace DependentAddressSpace |
3495 | |
3496 | namespace DependentSizedExtVector { |
3497 | #if defined(FIRST) |
3498 | template<int Size> |
3499 | void invalid1() { |
3500 | typedef int __attribute__((ext_vector_type(Size))) type; |
3501 | } |
3502 | template<int Size> |
3503 | void invalid2() { |
3504 | typedef int __attribute__((ext_vector_type(Size + 0))) type; |
3505 | } |
3506 | template<int Size> |
3507 | void valid() { |
3508 | typedef int __attribute__((ext_vector_type(Size))) type; |
3509 | } |
3510 | #elif defined(SECOND) |
3511 | template<int Size> |
3512 | void invalid1() { |
3513 | typedef float __attribute__((ext_vector_type(Size))) type; |
3514 | } |
3515 | template<int Size> |
3516 | void invalid2() { |
3517 | typedef int __attribute__((ext_vector_type(Size + 1))) type; |
3518 | } |
3519 | template<int Size> |
3520 | void valid() { |
3521 | typedef int __attribute__((ext_vector_type(Size))) type; |
3522 | } |
3523 | #else |
3524 | template <int Num> |
3525 | class S { |
3526 | static auto Function1 = invalid1<Num>; |
3527 | // expected-error@first.h:* {{'Types::DependentSizedExtVector::invalid1' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}} |
3528 | // expected-note@second.h:* {{but in 'SecondModule' found a different body}} |
3529 | static auto Function2 = invalid2<Num>; |
3530 | // expected-error@first.h:* {{'Types::DependentSizedExtVector::invalid2' has different definitions in different modules; definition in module 'FirstModule' first difference is function body}} |
3531 | // expected-note@second.h:* {{but in 'SecondModule' found a different body}} |
3532 | static auto Function3 = valid<Num>; |
3533 | }; |
3534 | #endif |
3535 | } // namespace DependentSizedExtVector |
3536 | |
3537 | namespace InjectedClassName { |
3538 | #if defined(FIRST) |
3539 | struct Invalid { |
3540 | template <int> |
3541 | struct L2 { |
3542 | template <int> |
3543 | struct L3 { |
3544 | L3 *x; |
3545 | }; |
3546 | }; |
3547 | }; |
3548 | struct Valid { |
3549 | template <int> |
3550 | struct L2 { |
3551 | template <int> |
3552 | struct L3 { |
3553 | L2 *x; |
3554 | L3 *y; |
3555 | }; |
3556 | }; |
3557 | }; |
3558 | #elif defined(SECOND) |
3559 | struct Invalid { |
3560 | template <int> |
3561 | struct L2 { |
3562 | template <int> |
3563 | struct L3 { |
3564 | L2 *x; |
3565 | }; |
3566 | }; |
3567 | }; |
3568 | struct Valid { |
3569 | template <int> |
3570 | struct L2 { |
3571 | template <int> |
3572 | struct L3 { |
3573 | L2 *x; |
3574 | L3 *y; |
3575 | }; |
3576 | }; |
3577 | }; |
3578 | #else |
3579 | Invalid::L2<1>::L3<1> invalid; |
3580 | // expected-error@second.h:* {{'Types::InjectedClassName::Invalid::L2::L3::x' from module 'SecondModule' is not present in definition of 'L3<>' in module 'FirstModule'}} |
3581 | // expected-note@first.h:* {{declaration of 'x' does not match}} |
3582 | Valid::L2<1>::L3<1> valid; |
3583 | #endif |
3584 | } // namespace InjectedClassName |
3585 | |
3586 | namespace MemberPointer { |
3587 | #if defined(FIRST) |
3588 | struct A {}; |
3589 | struct B {}; |
3590 | |
3591 | void Invalid1() { |
3592 | int A::*x; |
3593 | }; |
3594 | void Invalid2() { |
3595 | int A::*x; |
3596 | } |
3597 | void Invalid3() { |
3598 | int (A::*x)(int); |
3599 | } |
3600 | void Valid() { |
3601 | int A::*x; |
3602 | float A::*y; |
3603 | bool B::*z; |
3604 | void (A::*fun1)(); |
3605 | int (A::*fun2)(); |
3606 | void (B::*fun3)(int); |
3607 | void (B::*fun4)(bool*, int); |
3608 | } |
3609 | #elif defined(SECOND) |
3610 | struct A {}; |
3611 | struct B {}; |
3612 | |
3613 | void Invalid1() { |
3614 | float A::*x; |
3615 | }; |
3616 | void Invalid2() { |
3617 | int B::*x; |
3618 | } |
3619 | void Invalid3() { |
3620 | int (A::*x)(int, int); |
3621 | } |
3622 | void Valid() { |
3623 | int A::*x; |
3624 | float A::*y; |
3625 | bool B::*z; |
3626 | void (A::*fun1)(); |
3627 | int (A::*fun2)(); |
3628 | void (B::*fun3)(int); |
3629 | void (B::*fun4)(bool*, int); |
3630 | } |
3631 | #else |
3632 | auto function1 = Invalid1; |
3633 | // expected-error@second.h:* {{'Types::MemberPointer::Invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3634 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3635 | auto function2 = Invalid2; |
3636 | // expected-error@second.h:* {{'Types::MemberPointer::Invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3637 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3638 | auto function3 = Invalid3; |
3639 | // expected-error@second.h:* {{'Types::MemberPointer::Invalid3' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3640 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3641 | auto function4 = Valid; |
3642 | #endif |
3643 | |
3644 | } // namespace MemberPointer |
3645 | |
3646 | namespace PackExpansion { |
3647 | #if defined(FIRST) |
3648 | struct Invalid { |
3649 | template <class... A> |
3650 | struct L2 { |
3651 | template <class... B> |
3652 | struct L3 { |
3653 | void run(A...); |
3654 | void run(B...); |
3655 | }; |
3656 | }; |
3657 | }; |
3658 | struct Valid { |
3659 | template <class... A> |
3660 | struct L2 { |
3661 | template <class... B> |
3662 | struct L3 { |
3663 | void run(A...); |
3664 | void run(B...); |
3665 | }; |
3666 | }; |
3667 | }; |
3668 | #elif defined(SECOND) |
3669 | struct Invalid { |
3670 | template <class... A> |
3671 | struct L2 { |
3672 | template <class... B> |
3673 | struct L3 { |
3674 | void run(B...); |
3675 | void run(A...); |
3676 | }; |
3677 | }; |
3678 | }; |
3679 | struct Valid { |
3680 | template <class... A> |
3681 | struct L2 { |
3682 | template <class... B> |
3683 | struct L3 { |
3684 | void run(A...); |
3685 | void run(B...); |
3686 | }; |
3687 | }; |
3688 | }; |
3689 | #else |
3690 | Invalid::L2<int>::L3<short, bool> invalid; |
3691 | // 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...'}} |
3692 | // expected-note@second.h:* {{but in 'SecondModule' found method 'run' with 1st parameter of type 'B...'}} |
3693 | Valid::L2<int>::L3<short, bool> valid; |
3694 | #endif |
3695 | |
3696 | } // namespace PackExpansion |
3697 | |
3698 | namespace Paren { |
3699 | #if defined(FIRST) |
3700 | void invalid() { |
3701 | int (*x); |
3702 | } |
3703 | void valid() { |
3704 | int (*x); |
3705 | } |
3706 | #elif defined(SECOND) |
3707 | void invalid() { |
3708 | float (*x); |
3709 | } |
3710 | void valid() { |
3711 | int (*x); |
3712 | } |
3713 | #else |
3714 | auto function1 = invalid; |
3715 | // expected-error@second.h:* {{'Types::Paren::invalid' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
3716 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
3717 | auto function2 = valid; |
3718 | #endif |
3719 | } // namespace Paren |
3720 | |
3721 | namespace SubstTemplateTypeParm { |
3722 | #if defined(FIRST) |
3723 | template <class> struct wrapper {}; |
3724 | template <class, class, class> struct triple {}; |
3725 | struct Valid { |
3726 | template <class T, |
3727 | template <class _T, class _U, class = wrapper<_T>> class A = triple> |
3728 | struct L2 { |
3729 | A<T, T> x; |
3730 | }; |
3731 | }; |
3732 | #elif defined(SECOND) |
3733 | template <class> struct wrapper {}; |
3734 | template <class, class, class> struct triple {}; |
3735 | struct Valid { |
3736 | template <class T, |
3737 | template <class _T, class _U, class = wrapper<_T>> class A = triple> |
3738 | struct L2 { |
3739 | A<T, T> x; |
3740 | }; |
3741 | }; |
3742 | #else |
3743 | template <class T, |
3744 | template <class _T, class _U, class = wrapper<_T>> class A = triple> |
3745 | using V = Valid::L2<T, A>; |
3746 | #endif |
3747 | } // namespace SubstTemplateTypeParm |
3748 | |
3749 | namespace SubstTemplateTypeParmPack { |
3750 | } // namespace SubstTemplateTypeParmPack |
3751 | |
3752 | namespace UnaryTransform { |
3753 | #if defined(FIRST) |
3754 | enum class E1a : unsigned {}; |
3755 | struct Invalid1 { |
3756 | __underlying_type(E1a) x; |
3757 | }; |
3758 | enum E2a : unsigned {}; |
3759 | struct Invalid2 { |
3760 | __underlying_type(E2a) x; |
3761 | }; |
3762 | enum E3a {}; |
3763 | struct Invalid3 { |
3764 | __underlying_type(E3a) x; |
3765 | }; |
3766 | enum E4a {}; |
3767 | struct Invalid4 { |
3768 | __underlying_type(E4a) x; |
3769 | }; |
3770 | enum E1 {}; |
3771 | struct Valid1 { |
3772 | __underlying_type(E1) x; |
3773 | }; |
3774 | enum E2 : unsigned {}; |
3775 | struct Valid2 { |
3776 | __underlying_type(E2) x; |
3777 | }; |
3778 | enum class E3 {}; |
3779 | struct Valid3 { |
3780 | __underlying_type(E3) x; |
3781 | }; |
3782 | #elif defined(SECOND) |
3783 | enum class E1b : signed {}; |
3784 | struct Invalid1 { |
3785 | __underlying_type(E1b) x; |
3786 | }; |
3787 | enum class E2b : unsigned {}; |
3788 | struct Invalid2 { |
3789 | __underlying_type(E2b) x; |
3790 | }; |
3791 | enum E3b : int {}; |
3792 | struct Invalid3 { |
3793 | __underlying_type(E3b) x; |
3794 | }; |
3795 | enum E4b {}; |
3796 | struct Invalid4 { |
3797 | __underlying_type(E4b) x; |
3798 | }; |
3799 | #else |
3800 | Invalid1 i1; |
3801 | // expected-error@first.h:* {{'Types::UnaryTransform::Invalid1::x' from module 'FirstModule' is not present in definition of 'Types::UnaryTransform::Invalid1' in module 'SecondModule'}} |
3802 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
3803 | Invalid2 i2; |
3804 | // 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(Types::UnaryTransform::E2b)' (aka 'unsigned int')}} |
3805 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type '__underlying_type(Types::UnaryTransform::E2a)' (aka 'unsigned int')}} |
3806 | Invalid3 i3; |
3807 | // expected-error@first.h:* {{'Types::UnaryTransform::Invalid3::x' from module 'FirstModule' is not present in definition of 'Types::UnaryTransform::Invalid3' in module 'SecondModule'}} |
3808 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
3809 | Invalid4 i4; |
3810 | // 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(Types::UnaryTransform::E4b)' (aka 'unsigned int')}} |
3811 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type '__underlying_type(Types::UnaryTransform::E4a)' (aka 'unsigned int')}} |
3812 | Valid1 v1; |
3813 | Valid2 v2; |
3814 | Valid3 v3; |
3815 | #endif |
3816 | } // namespace UnaryTransform |
3817 | |
3818 | namespace UnresolvedUsing { |
3819 | #if defined(FIRST) |
3820 | template <class T> struct wrapper {}; |
3821 | template <class T> |
3822 | struct Invalid { |
3823 | using typename wrapper<T>::T1; |
3824 | using typename wrapper<T>::T2; |
3825 | T1 x; |
3826 | }; |
3827 | template <class T> |
3828 | struct Valid { |
3829 | using typename wrapper<T>::T1; |
3830 | using typename wrapper<T>::T2; |
3831 | T1 x; |
3832 | T2 y; |
3833 | }; |
3834 | #elif defined(SECOND) |
3835 | template <class T> struct wrapper {}; |
3836 | template <class T> |
3837 | struct Invalid { |
3838 | using typename wrapper<T>::T1; |
3839 | using typename wrapper<T>::T2; |
3840 | T2 x; |
3841 | }; |
3842 | template <class T> |
3843 | struct Valid { |
3844 | using typename wrapper<T>::T1; |
3845 | using typename wrapper<T>::T2; |
3846 | T1 x; |
3847 | T2 y; |
3848 | }; |
3849 | #else |
3850 | template <class T> using I = Invalid<T>; |
3851 | // expected-error@first.h:* {{'Types::UnresolvedUsing::Invalid::x' from module 'FirstModule' is not present in definition of 'Invalid<T>' in module 'SecondModule'}} |
3852 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
3853 | |
3854 | template <class T> using V = Valid<T>; |
3855 | #endif |
3856 | |
3857 | } // namespace UnresolvedUsing |
3858 | |
3859 | // Vector |
3860 | // void invalid1() { |
3861 | // __attribute((vector_size(8))) int *x1; |
3862 | //} |
3863 | |
3864 | } // namespace Types |
3865 | |
3866 | // Collection of interesting cases below. |
3867 | |
3868 | // Naive parsing of AST can lead to cycles in processing. Ensure |
3869 | // self-references don't trigger an endless cycles of AST node processing. |
3870 | namespace SelfReference { |
3871 | #if defined(FIRST) |
3872 | template <template <int> class T> class Wrapper {}; |
3873 | |
3874 | template <int N> class S { |
3875 | S(Wrapper<::SelfReference::S> &Ref) {} |
3876 | }; |
3877 | |
3878 | struct Xx { |
3879 | struct Yy { |
3880 | }; |
3881 | }; |
3882 | |
3883 | Xx::Xx::Xx::Yy yy; |
3884 | |
3885 | namespace NNS { |
3886 | template <typename> struct Foo; |
3887 | template <template <class> class T = NNS::Foo> |
3888 | struct NestedNamespaceSpecifier {}; |
3889 | } |
3890 | #endif |
3891 | } // namespace SelfReference |
3892 | |
3893 | namespace FriendFunction { |
3894 | #if defined(FIRST) |
3895 | void F(int = 0); |
3896 | struct S { friend void F(int); }; |
3897 | #elif defined(SECOND) |
3898 | void F(int); |
3899 | struct S { friend void F(int); }; |
3900 | #else |
3901 | S s; |
3902 | #endif |
3903 | |
3904 | #if defined(FIRST) |
3905 | void G(int = 0); |
3906 | struct T { |
3907 | friend void G(int); |
3908 | |
3909 | private: |
3910 | }; |
3911 | #elif defined(SECOND) |
3912 | void G(int); |
3913 | struct T { |
3914 | friend void G(int); |
3915 | |
3916 | public: |
3917 | }; |
3918 | #else |
3919 | T t; |
3920 | // expected-error@second.h:* {{'FriendFunction::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
3921 | // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}} |
3922 | #endif |
3923 | } // namespace FriendFunction |
3924 | |
3925 | namespace ImplicitDecl { |
3926 | #if defined(FIRST) |
3927 | struct S { }; |
3928 | void S_Constructors() { |
3929 | // Trigger creation of implicit contructors |
3930 | S foo; |
3931 | S bar = foo; |
3932 | S baz(bar); |
3933 | } |
3934 | #elif defined(SECOND) |
3935 | struct S { }; |
3936 | #else |
3937 | S s; |
3938 | #endif |
3939 | |
3940 | #if defined(FIRST) |
3941 | struct T { |
3942 | private: |
3943 | }; |
3944 | void T_Constructors() { |
3945 | // Trigger creation of implicit contructors |
3946 | T foo; |
3947 | T bar = foo; |
3948 | T baz(bar); |
3949 | } |
3950 | #elif defined(SECOND) |
3951 | struct T { |
3952 | public: |
3953 | }; |
3954 | #else |
3955 | T t; |
3956 | // expected-error@first.h:* {{'ImplicitDecl::T' has different definitions in different modules; first difference is definition in module 'FirstModule' found private access specifier}} |
3957 | // expected-note@second.h:* {{but in 'SecondModule' found public access specifier}} |
3958 | #endif |
3959 | |
3960 | } // namespace ImplicitDecl |
3961 | |
3962 | namespace TemplatedClass { |
3963 | #if defined(FIRST) |
3964 | template <class> |
3965 | struct S {}; |
3966 | #elif defined(SECOND) |
3967 | template <class> |
3968 | struct S {}; |
3969 | #else |
3970 | S<int> s; |
3971 | #endif |
3972 | |
3973 | #if defined(FIRST) |
3974 | template <class> |
3975 | struct T { |
3976 | private: |
3977 | }; |
3978 | #elif defined(SECOND) |
3979 | template <class> |
3980 | struct T { |
3981 | public: |
3982 | }; |
3983 | #else |
3984 | T<int> t; |
3985 | // expected-error@second.h:* {{'TemplatedClass::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
3986 | // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}} |
3987 | #endif |
3988 | } // namespace TemplatedClass |
3989 | |
3990 | namespace TemplateClassWithField { |
3991 | #if defined(FIRST) |
3992 | template <class A> |
3993 | struct S { |
3994 | A a; |
3995 | }; |
3996 | #elif defined(SECOND) |
3997 | template <class A> |
3998 | struct S { |
3999 | A a; |
4000 | }; |
4001 | #else |
4002 | S<int> s; |
4003 | #endif |
4004 | |
4005 | #if defined(FIRST) |
4006 | template <class A> |
4007 | struct T { |
4008 | A a; |
4009 | |
4010 | private: |
4011 | }; |
4012 | #elif defined(SECOND) |
4013 | template <class A> |
4014 | struct T { |
4015 | A a; |
4016 | |
4017 | public: |
4018 | }; |
4019 | #else |
4020 | T<int> t; |
4021 | // expected-error@second.h:* {{'TemplateClassWithField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
4022 | // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}} |
4023 | #endif |
4024 | } // namespace TemplateClassWithField |
4025 | |
4026 | namespace TemplateClassWithTemplateField { |
4027 | #if defined(FIRST) |
4028 | template <class A> |
4029 | class WrapperS; |
4030 | template <class A> |
4031 | struct S { |
4032 | WrapperS<A> a; |
4033 | }; |
4034 | #elif defined(SECOND) |
4035 | template <class A> |
4036 | class WrapperS; |
4037 | template <class A> |
4038 | struct S { |
4039 | WrapperS<A> a; |
4040 | }; |
4041 | #else |
4042 | template <class A> |
4043 | class WrapperS{}; |
4044 | S<int> s; |
4045 | #endif |
4046 | |
4047 | #if defined(FIRST) |
4048 | template <class A> |
4049 | class WrapperT; |
4050 | template <class A> |
4051 | struct T { |
4052 | WrapperT<A> a; |
4053 | |
4054 | public: |
4055 | }; |
4056 | #elif defined(SECOND) |
4057 | template <class A> |
4058 | class WrapperT; |
4059 | template <class A> |
4060 | struct T { |
4061 | WrapperT<A> a; |
4062 | |
4063 | private: |
4064 | }; |
4065 | #else |
4066 | template <class A> |
4067 | class WrapperT{}; |
4068 | T<int> t; |
4069 | // expected-error@second.h:* {{'TemplateClassWithTemplateField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
4070 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
4071 | #endif |
4072 | } // namespace TemplateClassWithTemplateField |
4073 | |
4074 | namespace EnumWithForwardDeclaration { |
4075 | #if defined(FIRST) |
4076 | enum E : int; |
4077 | struct S { |
4078 | void get(E) {} |
4079 | }; |
4080 | #elif defined(SECOND) |
4081 | enum E : int { A, B }; |
4082 | struct S { |
4083 | void get(E) {} |
4084 | }; |
4085 | #else |
4086 | S s; |
4087 | #endif |
4088 | |
4089 | #if defined(FIRST) |
4090 | struct T { |
4091 | void get(E) {} |
4092 | public: |
4093 | }; |
4094 | #elif defined(SECOND) |
4095 | struct T { |
4096 | void get(E) {} |
4097 | private: |
4098 | }; |
4099 | #else |
4100 | T t; |
4101 | // expected-error@second.h:* {{'EnumWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
4102 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
4103 | #endif |
4104 | } // namespace EnumWithForwardDeclaration |
4105 | |
4106 | namespace StructWithForwardDeclaration { |
4107 | #if defined(FIRST) |
4108 | struct P {}; |
4109 | struct S { |
4110 | struct P *ptr; |
4111 | }; |
4112 | #elif defined(SECOND) |
4113 | struct S { |
4114 | struct P *ptr; |
4115 | }; |
4116 | #else |
4117 | S s; |
4118 | #endif |
4119 | |
4120 | #if defined(FIRST) |
4121 | struct Q {}; |
4122 | struct T { |
4123 | struct Q *ptr; |
4124 | public: |
4125 | }; |
4126 | #elif defined(SECOND) |
4127 | struct T { |
4128 | struct Q *ptr; |
4129 | private: |
4130 | }; |
4131 | #else |
4132 | T t; |
4133 | // expected-error@second.h:* {{'StructWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
4134 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
4135 | #endif |
4136 | } // namespace StructWithForwardDeclaration |
4137 | |
4138 | namespace StructWithForwardDeclarationNoDefinition { |
4139 | #if defined(FIRST) |
4140 | struct P; |
4141 | struct S { |
4142 | struct P *ptr; |
4143 | }; |
4144 | #elif defined(SECOND) |
4145 | struct S { |
4146 | struct P *ptr; |
4147 | }; |
4148 | #else |
4149 | S s; |
4150 | #endif |
4151 | |
4152 | #if defined(FIRST) |
4153 | struct Q; |
4154 | struct T { |
4155 | struct Q *ptr; |
4156 | |
4157 | public: |
4158 | }; |
4159 | #elif defined(SECOND) |
4160 | struct T { |
4161 | struct Q *ptr; |
4162 | |
4163 | private: |
4164 | }; |
4165 | #else |
4166 | T t; |
4167 | // expected-error@second.h:* {{'StructWithForwardDeclarationNoDefinition::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
4168 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
4169 | #endif |
4170 | } // namespace StructWithForwardDeclarationNoDefinition |
4171 | |
4172 | namespace LateParsedDefaultArgument { |
4173 | #if defined(FIRST) |
4174 | template <typename T> |
4175 | struct S { |
4176 | struct R { |
4177 | void foo(T x = 0) {} |
4178 | }; |
4179 | }; |
4180 | #elif defined(SECOND) |
4181 | #else |
4182 | void run() { |
4183 | S<int>::R().foo(); |
4184 | } |
4185 | #endif |
4186 | } // namespace LateParsedDefaultArgument |
4187 | |
4188 | namespace LateParsedDefaultArgument { |
4189 | #if defined(FIRST) |
4190 | template <typename alpha> struct Bravo { |
4191 | void charlie(bool delta = false) {} |
4192 | }; |
4193 | typedef Bravo<char> echo; |
4194 | echo foxtrot; |
4195 | |
4196 | Bravo<char> golf; |
4197 | #elif defined(SECOND) |
4198 | #else |
4199 | #endif |
4200 | } // LateParsedDefaultArgument |
4201 | |
4202 | namespace DifferentParameterNameInTemplate { |
4203 | #if defined(FIRST) || defined(SECOND) |
4204 | template <typename T> |
4205 | struct S { |
4206 | typedef T Type; |
4207 | |
4208 | static void Run(const Type *name_one); |
4209 | }; |
4210 | |
4211 | template <typename T> |
4212 | void S<T>::Run(const T *name_two) {} |
4213 | |
4214 | template <typename T> |
4215 | struct Foo { |
4216 | ~Foo() { Handler::Run(nullptr); } |
4217 | Foo() {} |
4218 | |
4219 | class Handler : public S<T> {}; |
4220 | |
4221 | void Get(typename Handler::Type *x = nullptr) {} |
4222 | void Add() { Handler::Run(nullptr); } |
4223 | }; |
4224 | #endif |
4225 | |
4226 | #if defined(FIRST) |
4227 | struct Beta; |
4228 | |
4229 | struct Alpha { |
4230 | Alpha(); |
4231 | void Go() { betas.Get(); } |
4232 | Foo<Beta> betas; |
4233 | }; |
4234 | |
4235 | #elif defined(SECOND) |
4236 | struct Beta {}; |
4237 | |
4238 | struct BetaHelper { |
4239 | void add_Beta() { betas.Add(); } |
4240 | Foo<Beta> betas; |
4241 | }; |
4242 | |
4243 | #else |
4244 | Alpha::Alpha() {} |
4245 | #endif |
4246 | } // DifferentParameterNameInTemplate |
4247 | |
4248 | namespace ParameterTest { |
4249 | #if defined(FIRST) |
4250 | class X {}; |
4251 | template <typename G> |
4252 | class S { |
4253 | public: |
4254 | typedef G Type; |
4255 | static inline G *Foo(const G *a, int * = nullptr); |
4256 | }; |
4257 | |
4258 | template<typename G> |
4259 | G* S<G>::Foo(const G* aaaa, int*) {} |
4260 | #elif defined(SECOND) |
4261 | template <typename G> |
4262 | class S { |
4263 | public: |
4264 | typedef G Type; |
4265 | static inline G *Foo(const G *a, int * = nullptr); |
4266 | }; |
4267 | |
4268 | template<typename G> |
4269 | G* S<G>::Foo(const G* asdf, int*) {} |
4270 | #else |
4271 | S<X> s; |
4272 | #endif |
4273 | } // ParameterTest |
4274 | |
4275 | namespace MultipleTypedefs { |
4276 | #if defined(FIRST) |
4277 | typedef int B1; |
4278 | typedef B1 A1; |
4279 | struct S1 { |
4280 | A1 x; |
4281 | }; |
4282 | #elif defined(SECOND) |
4283 | typedef int A1; |
4284 | struct S1 { |
4285 | A1 x; |
4286 | }; |
4287 | #else |
4288 | S1 s1; |
4289 | #endif |
4290 | |
4291 | #if defined(FIRST) |
4292 | struct T2 { int x; }; |
4293 | typedef T2 B2; |
4294 | typedef B2 A2; |
4295 | struct S2 { |
4296 | T2 x; |
4297 | }; |
4298 | #elif defined(SECOND) |
4299 | struct T2 { int x; }; |
4300 | typedef T2 A2; |
4301 | struct S2 { |
4302 | T2 x; |
4303 | }; |
4304 | #else |
4305 | S2 s2; |
4306 | #endif |
4307 | |
4308 | #if defined(FIRST) |
4309 | using A3 = const int; |
4310 | using B3 = volatile A3; |
4311 | struct S3 { |
4312 | B3 x = 1; |
4313 | }; |
4314 | #elif defined(SECOND) |
4315 | using A3 = volatile const int; |
4316 | using B3 = A3; |
4317 | struct S3 { |
4318 | B3 x = 1; |
4319 | }; |
4320 | #else |
4321 | S3 s3; |
4322 | #endif |
4323 | |
4324 | #if defined(FIRST) |
4325 | using A4 = int; |
4326 | using B4 = A4; |
4327 | struct S4 { |
4328 | B4 x; |
4329 | }; |
4330 | #elif defined(SECOND) |
4331 | using A4 = int; |
4332 | using B4 = ::MultipleTypedefs::A4; |
4333 | struct S4 { |
4334 | B4 x; |
4335 | }; |
4336 | #else |
4337 | S4 s4; |
4338 | #endif |
4339 | |
4340 | #if defined(FIRST) |
4341 | using A5 = int; |
4342 | using B5 = MultipleTypedefs::A5; |
4343 | struct S5 { |
4344 | B5 x; |
4345 | }; |
4346 | #elif defined(SECOND) |
4347 | using A5 = int; |
4348 | using B5 = ::MultipleTypedefs::A5; |
4349 | struct S5 { |
4350 | B5 x; |
4351 | }; |
4352 | #else |
4353 | S5 s5; |
4354 | #endif |
4355 | } // MultipleTypedefs |
4356 | |
4357 | namespace DefaultArguments { |
4358 | #if defined(FIRST) |
4359 | template <typename T> |
4360 | struct S { |
4361 | struct R { |
4362 | void foo(T x = 0); |
4363 | }; |
4364 | }; |
4365 | #elif defined(SECOND) |
4366 | template <typename T> |
4367 | struct S { |
4368 | struct R { |
4369 | void foo(T x = 1); |
4370 | }; |
4371 | }; |
4372 | #else |
4373 | void run() { |
4374 | S<int>::R().foo(); |
4375 | } |
4376 | // 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}} |
4377 | // expected-note@first.h:* {{but in 'FirstModule' found method 'foo' with 1st parameter with a different default argument}} |
4378 | #endif |
4379 | |
4380 | #if defined(FIRST) |
4381 | template <typename alpha> struct Bravo { |
4382 | void charlie(bool delta = false); |
4383 | }; |
4384 | typedef Bravo<char> echo; |
4385 | echo foxtrot; |
4386 | #elif defined(SECOND) |
4387 | template <typename alpha> struct Bravo { |
4388 | void charlie(bool delta = (false)); |
4389 | }; |
4390 | typedef Bravo<char> echo; |
4391 | echo foxtrot; |
4392 | #else |
4393 | Bravo<char> golf; |
4394 | // 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}} |
4395 | // expected-note@first.h:* {{but in 'FirstModule' found method 'charlie' with 1st parameter with a different default argument}} |
4396 | #endif |
4397 | } // namespace DefaultArguments |
4398 | |
4399 | namespace FunctionDecl { |
4400 | #if defined(FIRST) |
4401 | struct S1 {}; |
4402 | S1 s1a; |
4403 | #elif defined(SECOND) |
4404 | struct S1 {}; |
4405 | #else |
4406 | S1 s1; |
4407 | #endif |
4408 | |
4409 | #if defined(FIRST) |
4410 | struct S2 { |
4411 | S2() = default; |
4412 | }; |
4413 | S2 s2a = S2(); |
4414 | #elif defined(SECOND) |
4415 | struct S2 { |
4416 | S2() = default; |
4417 | }; |
4418 | #else |
4419 | S2 s2; |
4420 | #endif |
4421 | |
4422 | #if defined(FIRST) |
4423 | struct S3 { |
4424 | S3() = delete; |
4425 | }; |
4426 | S3* s3c; |
4427 | #elif defined(SECOND) |
4428 | struct S3 { |
4429 | S3() = delete; |
4430 | }; |
4431 | #else |
4432 | S3* s3; |
4433 | #endif |
4434 | |
4435 | #if defined(FIRST) || defined(SECOND) |
4436 | int F1(int x, float y = 2.7) { return 1; } |
4437 | #else |
4438 | int I1 = F1(1); |
4439 | #endif |
4440 | |
4441 | #if defined(FIRST) |
4442 | int F2() { return 1; } |
4443 | #elif defined(SECOND) |
4444 | double F2() { return 1; } |
4445 | #else |
4446 | int I2 = F2(); |
4447 | // expected-error@-1 {{call to 'F2' is ambiguous}} |
4448 | // expected-note@first.h:* {{candidate function}} |
4449 | // expected-note@second.h:* {{candidate function}} |
4450 | #endif |
4451 | |
4452 | #if defined(FIRST) |
4453 | int F3(float) { return 1; } |
4454 | #elif defined(SECOND) |
4455 | int F3(double) { return 1; } |
4456 | #else |
4457 | int I3 = F3(1); |
4458 | // expected-error@-1 {{call to 'F3' is ambiguous}} |
4459 | // expected-note@first.h:* {{candidate function}} |
4460 | // expected-note@second.h:* {{candidate function}} |
4461 | #endif |
4462 | |
4463 | #if defined(FIRST) |
4464 | int F4(int x) { return 1; } |
4465 | #elif defined(SECOND) |
4466 | int F4(int y) { return 1; } |
4467 | #else |
4468 | int I4 = F4(1); |
4469 | // expected-error@second.h:* {{'FunctionDecl::F4' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with name 'y'}} |
4470 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with name 'x'}} |
4471 | #endif |
4472 | |
4473 | #if defined(FIRST) |
4474 | int F5(int x) { return 1; } |
4475 | #elif defined(SECOND) |
4476 | int F5(int x = 1) { return 1; } |
4477 | #else |
4478 | int I5 = F6(1); |
4479 | // 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}} |
4480 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a default argument}} |
4481 | #endif |
4482 | |
4483 | #if defined(FIRST) |
4484 | int F6(int x = 2) { return 1; } |
4485 | #elif defined(SECOND) |
4486 | int F6(int x = 1) { return 1; } |
4487 | #else |
4488 | int I6 = F6(1); |
4489 | // 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}} |
4490 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a different default argument}} |
4491 | #endif |
4492 | |
4493 | using I = int; |
4494 | #if defined(FIRST) |
4495 | I F7() { return 0; } |
4496 | #elif defined(SECOND) |
4497 | int F7() { return 0; } |
4498 | #else |
4499 | int I7 = F7(); |
4500 | // expected-error@second.h:* {{'FunctionDecl::F7' has different definitions in different modules; definition in module 'SecondModule' first difference is return type is 'int'}} |
4501 | // expected-note@first.h:* {{but in 'FirstModule' found different return type 'FunctionDecl::I' (aka 'int')}} |
4502 | #endif |
4503 | |
4504 | #if defined(FIRST) |
4505 | int F8(int) { return 0; } |
4506 | #elif defined(SECOND) |
4507 | int F8(I) { return 0; } |
4508 | #else |
4509 | int I8 = F8(1); |
4510 | // expected-error@second.h:* {{'FunctionDecl::F8' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with type 'FunctionDecl::I' (aka 'int')}} |
4511 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int'}} |
4512 | #endif |
4513 | |
4514 | #if defined(FIRST) |
4515 | int F9(int[1]) { return 0; } |
4516 | #elif defined(SECOND) |
4517 | int F9(int[2]) { return 0; } |
4518 | #else |
4519 | int I9 = F9(nullptr); |
4520 | // 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]'}} |
4521 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int *' decayed from 'int [1]'}} |
4522 | #endif |
4523 | |
4524 | #if defined(FIRST) |
4525 | int F10() { return 1; } |
4526 | #elif defined(SECOND) |
4527 | int F10() { return 2; } |
4528 | #else |
4529 | int I10 = F10(); |
4530 | #endif |
4531 | // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
4532 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
4533 | |
4534 | #if defined(FIRST) |
4535 | struct S11 { |
4536 | template <int> void foo(); |
4537 | }; |
4538 | #elif defined(SECOND) |
4539 | struct S11 { |
4540 | template <int> void foo(); |
4541 | }; |
4542 | template <int> void S11::foo() {} |
4543 | #else |
4544 | S11 s11; |
4545 | #endif |
4546 | |
4547 | #if defined(FIRST) |
4548 | struct S12 { |
4549 | void foo(int x); |
4550 | }; |
4551 | #elif defined(SECOND) |
4552 | struct S12 { |
4553 | void foo(int x); |
4554 | }; |
4555 | void S12::foo(int y) {} |
4556 | #else |
4557 | S12 s12; |
4558 | #endif |
4559 | |
4560 | #if defined(FIRST) |
4561 | struct S13 { |
4562 | void foo(int x); |
4563 | }; |
4564 | void S13::foo(int y) {} |
4565 | #elif defined(SECOND) |
4566 | struct S13 { |
4567 | void foo(int x); |
4568 | }; |
4569 | void S13::foo(int y) {} |
4570 | #else |
4571 | S13 s13; |
4572 | #endif |
4573 | } // namespace FunctionDecl |
4574 | |
4575 | namespace DeclTemplateArguments { |
4576 | #if defined(FIRST) |
4577 | int foo() { return 1; } |
4578 | int bar() { return foo(); } |
4579 | #elif defined(SECOND) |
4580 | template <class T = int> |
4581 | int foo() { return 2; } |
4582 | int bar() { return foo<>(); } |
4583 | #else |
4584 | int num = bar(); |
4585 | // expected-error@second.h:* {{'DeclTemplateArguments::bar' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
4586 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
4587 | #endif |
4588 | } |
4589 | |
4590 | // Keep macros contained to one file. |
4591 | #ifdef FIRST |
4592 | #undef FIRST |
4593 | #endif |
4594 | |
4595 | #ifdef SECOND |
4596 | #undef SECOND |
4597 | #endif |
4598 | |
4599 | #ifdef ACCESS |
4600 | #undef ACCESS |
4601 | #endif |
4602 | |