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