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