Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 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 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 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 |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 28 | // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++1z |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 29 | |
| 30 | #if !defined(FIRST) && !defined(SECOND) |
| 31 | #include "first.h" |
| 32 | #include "second.h" |
| 33 | #endif |
| 34 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 35 | // Used for testing |
| 36 | #if defined(FIRST) |
| 37 | #define ACCESS public: |
| 38 | #elif defined(SECOND) |
| 39 | #define ACCESS private: |
| 40 | #endif |
| 41 | |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'AccessSpecifiers::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 53 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'AccessSpecifiers::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found protected access specifier}} |
| 67 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 68 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'AccessSpecifiers::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 91 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 92 | #endif |
| 93 | |
| 94 | #undef DECLS |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 95 | } // namespace AccessSpecifiers |
| 96 | |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'StaticAssert::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with message}} |
| 109 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'StaticAssert::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with no message}} |
| 123 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'StaticAssert::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found static assert with condition}} |
| 137 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'StaticAssert::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
| 151 | // expected-note@first.h:* {{but in 'FirstModule' found static assert}} |
| 152 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'StaticAssert::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 174 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 175 | #endif |
| 176 | #undef DECLS |
| 177 | } // namespace StaticAssert |
Richard Trieu | 639d7b6 | 2017-02-22 22:22:42 +0000 | [diff] [blame] | 178 | |
Richard Trieu | d078609 | 2017-02-23 00:23:01 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Field::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}} |
| 194 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Field::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}} |
| 210 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x'}} |
| 211 | #endif |
Richard Trieu | bcaaf96 | 2017-02-23 03:25:57 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'Field::S3::x' from module 'FirstModule' is not present in definition of 'Field::S3' in module 'SecondModule'}} |
| 224 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 225 | #endif |
Richard Trieu | 8459ddf | 2017-02-24 02:59:12 +0000 | [diff] [blame] | 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; |
Alex Lorenz | 76377dc | 2017-03-10 15:04:58 +0000 | [diff] [blame] | 247 | // expected-error@second.h:* {{'Field::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'Field::B' (aka 'int')}} |
| 248 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'Field::A' (aka 'int')}} |
Richard Trieu | 8459ddf | 2017-02-24 02:59:12 +0000 | [diff] [blame] | 249 | |
| 250 | S5 s5; |
| 251 | // expected-error@second.h:* {{'Field::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'int'}} |
Alex Lorenz | 76377dc | 2017-03-10 15:04:58 +0000 | [diff] [blame] | 252 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'Field::A' (aka 'int')}} |
Richard Trieu | 8459ddf | 2017-02-24 02:59:12 +0000 | [diff] [blame] | 253 | #endif |
| 254 | |
Richard Trieu | 93772fc | 2017-02-24 20:59:28 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Field::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found bitfield 'x'}} |
| 266 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Field::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found bitfield 'x' with one width expression}} |
| 280 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Field::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found bitfield 'x' with one width expression}} |
| 294 | // expected-note@first.h:* {{but in 'FirstModule' found bitfield 'x' with different width expression}} |
| 295 | #endif |
Richard Trieu | 8459ddf | 2017-02-24 02:59:12 +0000 | [diff] [blame] | 296 | |
Richard Trieu | 8d543e2 | 2017-02-24 23:35:37 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Field::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found non-mutable field 'x'}} |
| 308 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Field::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with no initalizer}} |
| 322 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Field::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with an initializer}} |
| 336 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with a different initializer}} |
| 337 | #endif |
| 338 | |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'Field::S12::x' from module 'FirstModule' is not present in definition of 'Field::S12' in module 'SecondModule'}} |
| 350 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'Field::S13::x' from module 'FirstModule' is not present in definition of 'Field::S13' in module 'SecondModule'}} |
| 364 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 365 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Field::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 395 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 396 | #endif |
| 397 | #undef DECLS |
Richard Trieu | d078609 | 2017-02-23 00:23:01 +0000 | [diff] [blame] | 398 | } // namespace Field |
| 399 | |
Richard Trieu | 4814374 | 2017-02-28 21:24:38 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Method::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 413 | // expected-note@first.h:* {{but in 'FirstModule' found 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 | // expected-error@second.h:* {{'Method::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'B'}} |
| 429 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A'}} |
| 430 | #endif |
Richard Trieu | 583e2c1 | 2017-03-04 00:08:58 +0000 | [diff] [blame] | 431 | |
| 432 | #if defined(FIRST) |
| 433 | struct S3 { |
| 434 | static void A() {} |
Richard Trieu | f4b54fe | 2017-03-04 03:04:15 +0000 | [diff] [blame] | 435 | void A(int) {} |
Richard Trieu | 583e2c1 | 2017-03-04 00:08:58 +0000 | [diff] [blame] | 436 | }; |
| 437 | #elif defined(SECOND) |
| 438 | struct S3 { |
Richard Trieu | f4b54fe | 2017-03-04 03:04:15 +0000 | [diff] [blame] | 439 | void A(int) {} |
| 440 | static void A() {} |
Richard Trieu | 583e2c1 | 2017-03-04 00:08:58 +0000 | [diff] [blame] | 441 | }; |
| 442 | #else |
| 443 | S3 s3; |
| 444 | // expected-error@second.h:* {{'Method::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not static}} |
| 445 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Method::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not virtual}} |
| 461 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Method::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is virtual}} |
| 477 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Method::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not inline}} |
| 491 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Method::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not volatile}} |
| 507 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Method::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' is not const}} |
| 523 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' is const}} |
| 524 | #endif |
| 525 | |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Method::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' that has 2 parameters}} |
| 539 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Method::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter of type 'float'}} |
| 555 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int'}} |
| 556 | #endif |
| 557 | |
| 558 | #if defined(FIRST) |
| 559 | struct S11 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 560 | void A(int x); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 561 | }; |
| 562 | #elif defined(SECOND) |
| 563 | struct S11 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 564 | void A(int y); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 565 | }; |
| 566 | #else |
| 567 | S11 s11; |
| 568 | // expected-error@second.h:* {{'Method::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter named 'y'}} |
| 569 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter named 'x'}} |
| 570 | #endif |
| 571 | |
| 572 | #if defined(FIRST) |
| 573 | struct S12 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 574 | void A(int x); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 575 | }; |
| 576 | #elif defined(SECOND) |
| 577 | struct S12 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 578 | void A(int x = 1); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 579 | }; |
| 580 | #else |
| 581 | S12 s12; |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 582 | // expected-error@second.h:* {{'Method::S12' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter without a default argument}} |
| 583 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a default argument}} |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 584 | #endif |
| 585 | |
| 586 | #if defined(FIRST) |
| 587 | struct S13 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 588 | void A(int x = 1 + 0); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 589 | }; |
| 590 | #elif defined(SECOND) |
| 591 | struct S13 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 592 | void A(int x = 1); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 593 | }; |
| 594 | #else |
| 595 | S13 s13; |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 596 | // expected-error@second.h:* {{'Method::S13' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter with a default argument}} |
| 597 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter with a different default argument}} |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 598 | #endif |
| 599 | |
| 600 | #if defined(FIRST) |
| 601 | struct S14 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 602 | void A(int x[2]); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 603 | }; |
| 604 | #elif defined(SECOND) |
| 605 | struct S14 { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 606 | void A(int x[3]); |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 607 | }; |
| 608 | #else |
| 609 | S14 s14; |
| 610 | // expected-error@second.h:* {{'Method::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [3]'}} |
| 611 | // expected-note@first.h:* {{but in 'FirstModule' found method 'A' with 1st parameter of type 'int *' decayed from 'int [2]'}} |
| 612 | #endif |
Richard Trieu | 9747a7c | 2017-07-14 01:36:41 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'Method::S15::A' from module 'FirstModule' is not present in definition of 'Method::S15' in module 'SecondModule'}} |
| 625 | // expected-note@second.h:* {{declaration of 'A' does not match}} |
| 626 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Method::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 658 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 659 | #endif |
| 660 | #undef DECLS |
Richard Trieu | 4814374 | 2017-02-28 21:24:38 +0000 | [diff] [blame] | 661 | } // namespace Method |
| 662 | |
Richard Trieu | 27c1b1a | 2018-07-10 01:40:50 +0000 | [diff] [blame^] | 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 | // expected-error@first.h:* {{'MethodBody::S2' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'BothBodies' with body}} |
| 687 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'MethodBody::S3' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstBody' with body}} |
| 701 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'MethodBody::S4' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'SecondBody' with no body}} |
| 715 | // expected-note@second.h:* {{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 | // expected-error@second.h:* {{'MethodBody::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'FirstBodySecondOutOfLine' with no body}} |
| 730 | // expected-note@first.h:* {{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 | // expected-error@first.h:* {{'MethodBody::S6' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstOutOfLineSecondBody' with no body}} |
| 745 | // expected-note@second.h:* {{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 | // expected-error@second.h:* {{'MethodBody::S7::BothOutOfLine' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
| 761 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'MethodBody::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'FirstBodySecondOutOfLine' with no body}} |
| 776 | // expected-note@first.h:* {{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 | // expected-error@first.h:* {{'MethodBody::S9' has different definitions in different modules; first difference is definition in module 'FirstModule' found method 'FirstOutOfLineSecondBody' with no body}} |
| 791 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'MethodBody::S10' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is deleted}} |
| 807 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'MethodBody::S11' has different definitions in different modules; first difference is definition in module 'FirstModule' found constructor is defaulted}} |
| 821 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'MethodBody::Invalid1' has different definitions in different modules; first difference is definition in module 'FirstModule' found public access specifier}} |
| 854 | // expected-note@second.h:* {{but in 'SecondModule' found private access specifier}} |
| 855 | #endif |
| 856 | #undef DECLS |
| 857 | } // namespace MethodBody |
| 858 | |
Richard Trieu | 1c71d51 | 2017-07-15 02:55:13 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Constructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'foo'}} |
| 873 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Constructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor that has 2 parameters}} |
| 889 | // expected-note@first.h:* {{but in 'FirstModule' found constructor that has 1 parameter}} |
| 890 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Constructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 913 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 914 | #endif |
| 915 | #undef DECLS |
Richard Trieu | 1c71d51 | 2017-07-15 02:55:13 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Destructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor}} |
| 932 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Destructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found destructor is not virtual}} |
| 948 | // expected-note@first.h:* {{but in 'FirstModule' found destructor is virtual}} |
| 949 | #endif |
| 950 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 951 | #if defined(FIRST) || defined(SECOND) |
| 952 | struct Valid1 { |
| 953 | ~Valid1(); |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 954 | }; |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 955 | #else |
| 956 | Valid1 v1; |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 957 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 958 | |
| 959 | #if defined(FIRST) || defined(SECOND) |
| 960 | struct Invalid1 { |
| 961 | ~Invalid1(); |
| 962 | ACCESS |
| 963 | }; |
| 964 | #else |
| 965 | Invalid1 i1; |
| 966 | // expected-error@second.h:* {{'Destructor::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 967 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Destructor::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 986 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 987 | #endif |
| 988 | } // namespace Destructor |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 989 | |
Richard Trieu | 33562c2 | 2017-03-08 00:13:19 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'TypeDef::S1::a' from module 'FirstModule' is not present in definition of 'TypeDef::S1' in module 'SecondModule'}} |
| 1002 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'TypeDef::S2::a' from module 'FirstModule' is not present in definition of 'TypeDef::S2' in module 'SecondModule'}} |
| 1016 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'TypeDef::S3::a' from module 'FirstModule' is not present in definition of 'TypeDef::S3' in module 'SecondModule'}} |
| 1032 | // expected-note@second.h:* {{declaration of 'a' does not match}} |
| 1033 | #endif |
Richard Trieu | 11d566a | 2017-06-12 21:58:22 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'TypeDef::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found typedef name 'b'}} |
| 1048 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'TypeDef::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}} |
| 1066 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'TypeDef::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found typedef 'b' with underlying type 'float'}} |
| 1083 | // expected-note@first.h:* {{but in 'FirstModule' found typedef 'b' with different underlying type 'TypeDef::F' (aka 'float')}} |
| 1084 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'TypeDef::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1111 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1112 | #endif |
| 1113 | #undef DECLS |
Richard Trieu | 33562c2 | 2017-03-08 00:13:19 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'Using::S1::a' from module 'FirstModule' is not present in definition of 'Using::S1' in module 'SecondModule'}} |
| 1128 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'Using::S2::a' from module 'FirstModule' is not present in definition of 'Using::S2' in module 'SecondModule'}} |
| 1142 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'Using::S3::a' from module 'FirstModule' is not present in definition of 'Using::S3' in module 'SecondModule'}} |
| 1158 | // expected-note@second.h:* {{declaration of 'a' does not match}} |
| 1159 | #endif |
Richard Trieu | 11d566a | 2017-06-12 21:58:22 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Using::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias name 'b'}} |
| 1174 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Using::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field}} |
| 1192 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Using::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'b' with underlying type 'float'}} |
| 1209 | // expected-note@first.h:* {{but in 'FirstModule' found type alias 'b' with different underlying type 'Using::F' (aka 'float')}} |
| 1210 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Using::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1237 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1238 | #endif |
| 1239 | #undef DECLS |
Richard Trieu | 33562c2 | 2017-03-08 00:13:19 +0000 | [diff] [blame] | 1240 | } // namespace Using |
| 1241 | |
Richard Trieu | 58bb7bd | 2017-05-17 02:29:02 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'RecordType::S1::x' from module 'FirstModule' is not present in definition of 'RecordType::S1' in module 'SecondModule'}} |
| 1256 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 1257 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'RecordType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1282 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1283 | #endif |
| 1284 | #undef DECLS |
| 1285 | } // namespace RecordType |
Richard Trieu | 58bb7bd | 2017-05-17 02:29:02 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'DependentType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T>' in module 'SecondModule'}} |
| 1302 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 1303 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'DependentType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1328 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1329 | #endif |
| 1330 | #undef DECLS |
| 1331 | } // namespace DependentType |
Richard Trieu | 58bb7bd | 2017-05-17 02:29:02 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'ElaboratedType::S1::x' from module 'FirstModule' is not present in definition of 'ElaboratedType::S1' in module 'SecondModule'}} |
| 1347 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 1348 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'ElaboratedType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1373 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1374 | #endif |
| 1375 | #undef DECLS |
| 1376 | } // namespace ElaboratedType |
Richard Trieu | 58bb7bd | 2017-05-17 02:29:02 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'Enum::S1::x' from module 'FirstModule' is not present in definition of 'Enum::S1' in module 'SecondModule'}} |
| 1392 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 1393 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Enum::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1418 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1419 | #endif |
| 1420 | #undef DECLS |
Richard Trieu | 58bb7bd | 2017-05-17 02:29:02 +0000 | [diff] [blame] | 1421 | } |
Hans Wennborg | 2270776 | 2017-04-12 16:40:26 +0000 | [diff] [blame] | 1422 | |
Richard Trieu | ce81b19 | 2017-05-17 03:23:35 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'LevelB1::LevelC1::Type' (aka 'int')}} |
| 1445 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'int'}} |
| 1460 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'LevelB3::Type' (aka 'int')}} |
| 1476 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'TB4::Type' (aka 'int')}} |
| 1492 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'T5::Type' (aka 'int')}} |
| 1508 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type '::NestedNamespaceSpecifier::I' (aka 'int')}} |
| 1524 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'z' with an initializer}} |
| 1543 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with an initializer}} |
| 1560 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'x' with type 'P9::I' (aka 'int')}} |
| 1578 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x' with type 'O9::I' (aka 'int')}} |
| 1579 | #endif |
Richard Trieu | 96b4164 | 2017-07-01 02:00:05 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::N10::S10::x' from module 'SecondModule' is not present in definition of 'NestedNamespaceSpecifier::N10::S10' in module 'FirstModule'}} |
| 1595 | // expected-note@first.h:* {{declaration of 'x' does not match}} |
| 1596 | #endif |
| 1597 | } |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 {}; |
Richard Trieu | ce81b19 | 2017-05-17 03:23:35 +0000 | [diff] [blame] | 1612 | } |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1632 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'NestedNamespaceSpecifier::Invalid2' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1661 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1662 | #endif |
| 1663 | #undef DECLS |
| 1664 | } // namespace NestedNamespaceSpecifier |
Richard Trieu | ce81b19 | 2017-05-17 03:23:35 +0000 | [diff] [blame] | 1665 | |
Richard Trieu | 96b4962 | 2017-05-31 00:31:58 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'TemplateSpecializationType::S1::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S1' in module 'SecondModule'}} |
| 1680 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'TemplateSpecializationType::S2::u' from module 'FirstModule' is not present in definition of 'TemplateSpecializationType::S2' in module 'SecondModule'}} |
| 1696 | // expected-note@second.h:* {{declaration of 'u' does not match}} |
| 1697 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'TemplateSpecializationType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1728 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1729 | #endif |
| 1730 | #undef DECLS |
| 1731 | } // namespace TemplateSpecializationType |
Richard Trieu | 96b4962 | 2017-05-31 00:31:58 +0000 | [diff] [blame] | 1732 | |
Richard Trieu | 3b261bb7 | 2017-06-13 22:21:18 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'TemplateArgument::S1::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 'SecondModule'}} |
| 1747 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 1748 | #endif |
Richard Trieu | 1dcb405 | 2017-06-14 01:28:00 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'TemplateArgument::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'T' with underlying type 'U2<(2)>'}} |
| 1763 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'TemplateArgument::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'T' with underlying type 'U3<1 + 1>'}} |
| 1779 | // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U3<2>'}} |
| 1780 | #endif |
| 1781 | |
Richard Trieu | ee132d6 | 2017-06-14 03:17:26 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}} |
| 1797 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 1798 | #endif |
Richard Trieu | 8844c52 | 2017-06-30 22:40:33 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'TemplateArgument::S5::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S5' in module 'SecondModule'}} |
| 1813 | // expected-note@second.h:* {{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 | // expected-error@second.h:* {{'TemplateArgument::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}} |
| 1831 | // expected-note@first.h:* {{but in 'FirstModule' found field 'x'}} |
| 1832 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 1833 | |
Richard Trieu | 7282d32 | 2018-04-25 00:31:15 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'TemplateArgument::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with no template arguments}} |
| 1847 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'TemplateArgument::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 2 template arguments}} |
| 1867 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'TemplateArgument::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 'b' for 1st template argument}} |
| 1885 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'TemplateArgument::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 'b' for 2nd template argument}} |
| 1903 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'TemplateArgument::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'run' with 3 template arguments}} |
| 1921 | // expected-note@first.h:* {{but in 'FirstModule' found method 'run' with 2 template arguments}} |
| 1922 | #endif |
| 1923 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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; \ |
Richard Trieu | 7282d32 | 2018-04-25 00:31:15 +0000 | [diff] [blame] | 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>() {} |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'TemplateArgument::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 1969 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 1970 | #endif |
| 1971 | #undef DECLS |
| 1972 | } // namespace TemplateArgument |
Richard Trieu | ee132d6 | 2017-06-14 03:17:26 +0000 | [diff] [blame] | 1973 | |
Richard Trieu | d9201d0 | 2017-06-15 01:35:06 +0000 | [diff] [blame] | 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 | // expected-error@first.h:* {{'TemplateTypeParmType::S1::x' from module 'FirstModule' is not present in definition of 'S1<T1, T2>' in module 'SecondModule'}} |
| 1988 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'TemplateTypeParmType::S2::x' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}} |
| 2010 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 2011 | // expected-error@first.h:* {{'TemplateTypeParmType::S2::type' from module 'FirstModule' is not present in definition of 'S2<T, U>' in module 'SecondModule'}} |
| 2012 | // expected-note@second.h:* {{declaration of 'type' does not match}} |
| 2013 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'TemplateTypeParmType::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 2045 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 2046 | #endif |
| 2047 | #undef DECLS |
| 2048 | } // namespace TemplateTypeParmType |
Richard Trieu | 3b261bb7 | 2017-06-13 22:21:18 +0000 | [diff] [blame] | 2049 | |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'VarDecl::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member with name 'y'}} |
| 2064 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'VarDecl::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' with type 'VarDecl::I' (aka 'int')}} |
| 2079 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'VarDecl::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' with an initializer}} |
| 2093 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'VarDecl::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' with an initializer}} |
| 2107 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'VarDecl::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member 'x' is not constexpr}} |
| 2121 | // expected-note@first.h:* {{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 | // expected-error@first.h:* {{'VarDecl::S6::x' from module 'FirstModule' is not present in definition of 'VarDecl::S6' in module 'SecondModule'}} |
| 2135 | // expected-note@second.h:* {{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 | // expected-error@first.h:* {{'VarDecl::S7::x' from module 'FirstModule' is not present in definition of 'VarDecl::S7' in module 'SecondModule'}} |
| 2149 | // expected-note@second.h:* {{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 | // expected-error@second.h:* {{'VarDecl::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found data member}} |
| 2165 | // expected-note@first.h:* {{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 | // expected-error@first.h:* {{'VarDecl::S9::x' from module 'FirstModule' is not present in definition of 'VarDecl::S9' in module 'SecondModule'}} |
| 2179 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 2180 | #endif |
| 2181 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 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; |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 2190 | #endif |
| 2191 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 2192 | #if defined(FIRST) || defined(SECOND) |
| 2193 | struct Valid1 { |
| 2194 | DECLS |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 2195 | }; |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 2196 | #else |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 2197 | Valid1 v1; |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 2198 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 2199 | |
| 2200 | #if defined(FIRST) || defined(SECOND) |
| 2201 | struct Invalid1 { |
| 2202 | DECLS |
| 2203 | ACCESS |
| 2204 | }; |
| 2205 | #else |
| 2206 | Invalid1 i1; |
| 2207 | // expected-error@second.h:* {{'VarDecl::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 2208 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 2209 | #endif |
| 2210 | #undef DECLS |
| 2211 | } // namespace VarDecl |
Richard Trieu | 6e13ff3 | 2017-06-16 02:44:29 +0000 | [diff] [blame] | 2212 | |
Richard Trieu | ac6a1b6 | 2017-07-08 02:04:42 +0000 | [diff] [blame] | 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 | // expected-error@second.h:* {{'Friend::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'Friend::T1'}} |
| 2227 | // expected-note@first.h:* {{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 | // expected-error@second.h:* {{'Friend::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'struct T2'}} |
| 2243 | // expected-note@first.h:* {{but in 'FirstModule' found friend 'class T2'}} |
| 2244 | #endif |
| 2245 | |
| 2246 | #if defined(FIRST) |
| 2247 | struct T3 {}; |
| 2248 | struct S3 { |
| 2249 | friend const T3; |
| 2250 | }; |
| 2251 | #elif defined(SECOND) |
| 2252 | struct T3 {}; |
| 2253 | struct S3 { |
| 2254 | friend T3; |
| 2255 | }; |
| 2256 | #else |
| 2257 | S3 s3; |
| 2258 | // expected-error@second.h:* {{'Friend::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend 'Friend::T3'}} |
| 2259 | // expected-note@first.h:* {{but in 'FirstModule' found friend 'const Friend::T3'}} |
| 2260 | #endif |
| 2261 | |
| 2262 | #if defined(FIRST) |
| 2263 | struct T4 {}; |
| 2264 | struct S4 { |
| 2265 | friend T4; |
| 2266 | }; |
| 2267 | #elif defined(SECOND) |
| 2268 | struct S4 { |
| 2269 | friend void T4(); |
| 2270 | }; |
| 2271 | #else |
| 2272 | S4 s4; |
| 2273 | // expected-error@second.h:* {{'Friend::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function}} |
| 2274 | // expected-note@first.h:* {{but in 'FirstModule' found friend class}} |
| 2275 | #endif |
| 2276 | |
| 2277 | #if defined(FIRST) |
| 2278 | struct S5 { |
| 2279 | friend void T5a(); |
| 2280 | }; |
| 2281 | #elif defined(SECOND) |
| 2282 | struct S5 { |
| 2283 | friend void T5b(); |
| 2284 | }; |
| 2285 | #else |
| 2286 | S5 s5; |
| 2287 | // expected-error@second.h:* {{'Friend::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found friend function 'T5b'}} |
| 2288 | // expected-note@first.h:* {{but in 'FirstModule' found friend function 'T5a'}} |
| 2289 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 2290 | |
| 2291 | #define DECLS \ |
| 2292 | friend class FriendA; \ |
| 2293 | friend struct FriendB; \ |
| 2294 | friend FriendC; \ |
| 2295 | friend const FriendD; \ |
| 2296 | friend void Function(); |
| 2297 | |
| 2298 | #if defined(FIRST) || defined(SECOND) |
| 2299 | class FriendA {}; |
| 2300 | class FriendB {}; |
| 2301 | class FriendC {}; |
| 2302 | class FriendD {}; |
| 2303 | #endif |
| 2304 | |
| 2305 | #if defined(FIRST) || defined(SECOND) |
| 2306 | struct Valid1 { |
| 2307 | DECLS |
| 2308 | }; |
| 2309 | #else |
| 2310 | Valid1 v1; |
| 2311 | #endif |
| 2312 | |
| 2313 | #if defined(FIRST) || defined(SECOND) |
| 2314 | struct Invalid1 { |
| 2315 | DECLS |
| 2316 | ACCESS |
| 2317 | }; |
| 2318 | #else |
| 2319 | Invalid1 i1; |
| 2320 | // expected-error@second.h:* {{'Friend::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 2321 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 2322 | #endif |
| 2323 | #undef DECLS |
| 2324 | } // namespace Friend |
Richard Trieu | 498117b | 2017-08-23 02:43:59 +0000 | [diff] [blame] | 2325 | |
| 2326 | namespace TemplateParameters { |
| 2327 | #if defined(FIRST) |
| 2328 | template <class A> |
| 2329 | struct S1 {}; |
| 2330 | #elif defined(SECOND) |
| 2331 | template <class B> |
| 2332 | struct S1 {}; |
| 2333 | #else |
| 2334 | using TemplateParameters::S1; |
| 2335 | // expected-error@second.h:* {{'TemplateParameters::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter 'B'}} |
| 2336 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}} |
| 2337 | #endif |
| 2338 | |
| 2339 | #if defined(FIRST) |
| 2340 | template <class A = double> |
| 2341 | struct S2 {}; |
| 2342 | #elif defined(SECOND) |
| 2343 | template <class A = int> |
| 2344 | struct S2 {}; |
| 2345 | #else |
| 2346 | using TemplateParameters::S2; |
| 2347 | // expected-error@second.h:* {{'TemplateParameters::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}} |
| 2348 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}} |
| 2349 | #endif |
| 2350 | |
| 2351 | #if defined(FIRST) |
| 2352 | template <class A = int> |
| 2353 | struct S3 {}; |
| 2354 | #elif defined(SECOND) |
| 2355 | template <class A> |
| 2356 | struct S3 {}; |
| 2357 | #else |
| 2358 | using TemplateParameters::S3; |
| 2359 | // expected-error@second.h:* {{'TemplateParameters::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with no default argument}} |
| 2360 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with default argument}} |
| 2361 | #endif |
| 2362 | |
| 2363 | #if defined(FIRST) |
| 2364 | template <int A> |
| 2365 | struct S4 {}; |
| 2366 | #elif defined(SECOND) |
| 2367 | template <int A = 2> |
| 2368 | struct S4 {}; |
| 2369 | #else |
| 2370 | using TemplateParameters::S4; |
| 2371 | // expected-error@second.h:* {{'TemplateParameters::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}} |
| 2372 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with no default argument}} |
| 2373 | #endif |
| 2374 | |
| 2375 | #if defined(FIRST) |
| 2376 | template <int> class S5_first {}; |
| 2377 | template <template<int> class A = S5_first> |
| 2378 | struct S5 {}; |
| 2379 | #elif defined(SECOND) |
| 2380 | template <int> class S5_second {}; |
| 2381 | template <template<int> class A = S5_second> |
| 2382 | struct S5 {}; |
| 2383 | #else |
| 2384 | using TemplateParameters::S5; |
| 2385 | // expected-error@second.h:* {{'TemplateParameters::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found template parameter with default argument}} |
| 2386 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter with different default argument}} |
| 2387 | #endif |
| 2388 | |
| 2389 | #if defined(FIRST) |
| 2390 | template <class A> |
| 2391 | struct S6 {}; |
| 2392 | #elif defined(SECOND) |
| 2393 | template <class> |
| 2394 | struct S6 {}; |
| 2395 | #else |
| 2396 | using TemplateParameters::S6; |
| 2397 | // expected-error@second.h:* {{'TemplateParameters::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found unnamed template parameter}} |
| 2398 | // expected-note@first.h:* {{but in 'FirstModule' found template parameter 'A'}} |
| 2399 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 2400 | |
| 2401 | #define DECLS |
| 2402 | |
| 2403 | #if defined(FIRST) || defined(SECOND) |
| 2404 | template <class> class DefaultArg; |
| 2405 | #endif |
| 2406 | |
| 2407 | #if defined(FIRST) || defined(SECOND) |
| 2408 | template <int, class, template <class> class, |
| 2409 | int A, class B, template <int> class C, |
| 2410 | int D = 1, class E = int, template <class F> class = DefaultArg> |
| 2411 | struct Valid1 { |
| 2412 | DECLS |
| 2413 | }; |
| 2414 | #else |
| 2415 | using TemplateParameters::Valid1; |
| 2416 | #endif |
| 2417 | |
| 2418 | #if defined(FIRST) || defined(SECOND) |
| 2419 | template <int, class, template <class> class, |
| 2420 | int A, class B, template <int> class C, |
| 2421 | int D = 1, class E = int, template <class F> class = DefaultArg> |
| 2422 | struct Invalid1 { |
| 2423 | DECLS |
| 2424 | ACCESS |
| 2425 | }; |
| 2426 | #else |
| 2427 | using TemplateParameters::Invalid1; |
| 2428 | // expected-error@second.h:* {{'TemplateParameters::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 2429 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 2430 | #endif |
| 2431 | #undef DECLS |
Richard Trieu | 498117b | 2017-08-23 02:43:59 +0000 | [diff] [blame] | 2432 | } // namespace TemplateParameters |
| 2433 | |
Richard Trieu | e13eabe | 2017-09-30 02:19:17 +0000 | [diff] [blame] | 2434 | namespace BaseClass { |
| 2435 | #if defined(FIRST) |
| 2436 | struct B1 {}; |
| 2437 | struct S1 : B1 {}; |
| 2438 | #elif defined(SECOND) |
| 2439 | struct S1 {}; |
| 2440 | #else |
| 2441 | S1 s1; |
| 2442 | // expected-error@second.h:* {{'BaseClass::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 base classes}} |
| 2443 | // expected-note@first.h:* {{but in 'FirstModule' found 1 base class}} |
| 2444 | #endif |
| 2445 | |
| 2446 | #if defined(FIRST) |
| 2447 | struct S2 {}; |
| 2448 | #elif defined(SECOND) |
| 2449 | struct B2 {}; |
| 2450 | struct S2 : virtual B2 {}; |
| 2451 | #else |
| 2452 | S2 s2; |
| 2453 | // expected-error@second.h:* {{'BaseClass::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 base class}} |
| 2454 | // expected-note@first.h:* {{but in 'FirstModule' found 0 base classes}} |
| 2455 | #endif |
| 2456 | |
| 2457 | #if defined(FIRST) |
| 2458 | struct B3a {}; |
| 2459 | struct S3 : B3a {}; |
| 2460 | #elif defined(SECOND) |
| 2461 | struct B3b {}; |
| 2462 | struct S3 : virtual B3b {}; |
| 2463 | #else |
| 2464 | S3 s3; |
| 2465 | // expected-error@second.h:* {{'BaseClass::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}} |
| 2466 | // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}} |
| 2467 | #endif |
| 2468 | |
| 2469 | #if defined(FIRST) |
| 2470 | struct B4a {}; |
| 2471 | struct S4 : B4a {}; |
| 2472 | #elif defined(SECOND) |
| 2473 | struct B4b {}; |
| 2474 | struct S4 : B4b {}; |
| 2475 | #else |
| 2476 | S4 s4; |
| 2477 | // expected-error@second.h:* {{'BaseClass::S4' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class with type 'BaseClass::B4b'}} |
| 2478 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class with different type 'BaseClass::B4a'}} |
| 2479 | #endif |
| 2480 | |
| 2481 | #if defined(FIRST) |
| 2482 | struct B5a {}; |
| 2483 | struct S5 : virtual B5a {}; |
| 2484 | #elif defined(SECOND) |
| 2485 | struct B5a {}; |
| 2486 | struct S5 : B5a {}; |
| 2487 | #else |
| 2488 | S5 s5; |
| 2489 | // expected-error@second.h:* {{'BaseClass::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found 0 virtual base classes}} |
| 2490 | // expected-note@first.h:* {{but in 'FirstModule' found 1 virtual base class}} |
| 2491 | #endif |
| 2492 | |
| 2493 | #if defined(FIRST) |
| 2494 | struct B6a {}; |
| 2495 | struct S6 : B6a {}; |
| 2496 | #elif defined(SECOND) |
| 2497 | struct B6a {}; |
| 2498 | struct S6 : virtual B6a {}; |
| 2499 | #else |
| 2500 | S6 s6; |
| 2501 | // expected-error@second.h:* {{'BaseClass::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1 virtual base class}} |
| 2502 | // expected-note@first.h:* {{but in 'FirstModule' found 0 virtual base classes}} |
| 2503 | #endif |
| 2504 | |
| 2505 | #if defined(FIRST) |
| 2506 | struct B7a {}; |
| 2507 | struct S7 : protected B7a {}; |
| 2508 | #elif defined(SECOND) |
| 2509 | struct B7a {}; |
| 2510 | struct S7 : B7a {}; |
| 2511 | #else |
| 2512 | S7 s7; |
| 2513 | // expected-error@second.h:* {{'BaseClass::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B7a' with no access specifier}} |
| 2514 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B7a' with protected access specifier}} |
| 2515 | #endif |
| 2516 | |
| 2517 | #if defined(FIRST) |
| 2518 | struct B8a {}; |
| 2519 | struct S8 : public B8a {}; |
| 2520 | #elif defined(SECOND) |
| 2521 | struct B8a {}; |
| 2522 | struct S8 : private B8a {}; |
| 2523 | #else |
| 2524 | S8 s8; |
| 2525 | // expected-error@second.h:* {{'BaseClass::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B8a' with private access specifier}} |
| 2526 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B8a' with public access specifier}} |
| 2527 | #endif |
| 2528 | |
| 2529 | #if defined(FIRST) |
| 2530 | struct B9a {}; |
| 2531 | struct S9 : private B9a {}; |
| 2532 | #elif defined(SECOND) |
| 2533 | struct B9a {}; |
| 2534 | struct S9 : public B9a {}; |
| 2535 | #else |
| 2536 | S9 s9; |
| 2537 | // expected-error@second.h:* {{'BaseClass::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B9a' with public access specifier}} |
| 2538 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B9a' with private access specifier}} |
| 2539 | #endif |
| 2540 | |
| 2541 | #if defined(FIRST) |
| 2542 | struct B10a {}; |
| 2543 | struct S10 : B10a {}; |
| 2544 | #elif defined(SECOND) |
| 2545 | struct B10a {}; |
| 2546 | struct S10 : protected B10a {}; |
| 2547 | #else |
| 2548 | S10 s10; |
| 2549 | // expected-error@second.h:* {{'BaseClass::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found 1st base class 'BaseClass::B10a' with protected access specifier}} |
| 2550 | // expected-note@first.h:* {{but in 'FirstModule' found 1st base class 'BaseClass::B10a' with no access specifier}} |
| 2551 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 2552 | |
| 2553 | #define DECLS |
| 2554 | |
| 2555 | #if defined(FIRST) || defined(SECOND) |
| 2556 | struct Base1 {}; |
| 2557 | struct Base2 {}; |
| 2558 | struct Base3 {}; |
| 2559 | struct Base4 {}; |
| 2560 | struct Base5 {}; |
| 2561 | #endif |
| 2562 | |
| 2563 | #if defined(FIRST) || defined(SECOND) |
| 2564 | struct Valid1 : |
| 2565 | Base1, virtual Base2, protected Base3, public Base4, private Base5 { |
| 2566 | |
| 2567 | DECLS |
| 2568 | }; |
| 2569 | #else |
| 2570 | Valid1 v1; |
| 2571 | #endif |
| 2572 | |
| 2573 | #if defined(FIRST) || defined(SECOND) |
| 2574 | struct Invalid1 : |
| 2575 | Base1, virtual Base2, protected Base3, public Base4, private Base5 { |
| 2576 | |
| 2577 | DECLS |
| 2578 | ACCESS |
| 2579 | }; |
| 2580 | #else |
| 2581 | Invalid1 i1; |
| 2582 | // expected-error@second.h:* {{'BaseClass::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 2583 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 2584 | #endif |
| 2585 | #undef DECLS |
Richard Trieu | e13eabe | 2017-09-30 02:19:17 +0000 | [diff] [blame] | 2586 | } // namespace BaseClass |
| 2587 | |
Richard Trieu | 15970af | 2018-04-13 22:34:43 +0000 | [diff] [blame] | 2588 | namespace PointersAndReferences { |
| 2589 | #if defined(FIRST) || defined(SECOND) |
| 2590 | template<typename> struct Wrapper{}; |
| 2591 | #endif |
| 2592 | |
| 2593 | #if defined(FIRST) |
| 2594 | struct S1 { |
| 2595 | Wrapper<int*> x; |
| 2596 | }; |
| 2597 | #elif defined(SECOND) |
| 2598 | struct S1 { |
| 2599 | Wrapper<float*> x; |
| 2600 | }; |
| 2601 | #else |
| 2602 | S1 s1; |
| 2603 | // expected-error@first.h:* {{PointersAndReferences::S1::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S1' in module 'SecondModule'}} |
| 2604 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 2605 | #endif |
| 2606 | |
| 2607 | #if defined(FIRST) |
| 2608 | struct S2 { |
| 2609 | Wrapper<int &&> x; |
| 2610 | }; |
| 2611 | #elif defined(SECOND) |
| 2612 | struct S2 { |
| 2613 | Wrapper<float &&> x; |
| 2614 | }; |
| 2615 | #else |
| 2616 | S2 s2; |
| 2617 | // expected-error@first.h:* {{PointersAndReferences::S2::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S2' in module 'SecondModule'}} |
| 2618 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 2619 | #endif |
| 2620 | |
| 2621 | #if defined(FIRST) |
| 2622 | struct S3 { |
| 2623 | Wrapper<int *> x; |
| 2624 | }; |
| 2625 | #elif defined(SECOND) |
| 2626 | struct S3 { |
| 2627 | Wrapper<float *> x; |
| 2628 | }; |
| 2629 | #else |
| 2630 | S3 s3; |
| 2631 | // expected-error@first.h:* {{PointersAndReferences::S3::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S3' in module 'SecondModule'}} |
| 2632 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 2633 | #endif |
| 2634 | |
| 2635 | #if defined(FIRST) |
| 2636 | struct S4 { |
| 2637 | Wrapper<int &> x; |
| 2638 | }; |
| 2639 | #elif defined(SECOND) |
| 2640 | struct S4 { |
| 2641 | Wrapper<float &> x; |
| 2642 | }; |
| 2643 | #else |
| 2644 | S4 s4; |
| 2645 | // expected-error@first.h:* {{PointersAndReferences::S4::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S4' in module 'SecondModule'}} |
| 2646 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 2647 | #endif |
| 2648 | |
| 2649 | #if defined(FIRST) |
| 2650 | struct S5 { |
| 2651 | Wrapper<S5 *> x; |
| 2652 | }; |
| 2653 | #elif defined(SECOND) |
| 2654 | struct S5 { |
| 2655 | Wrapper<const S5 *> x; |
| 2656 | }; |
| 2657 | #else |
| 2658 | S5 s5; |
| 2659 | // expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 'SecondModule' is not present in definition of 'PointersAndReferences::S5' in module 'FirstModule'}} |
| 2660 | // expected-note@first.h:* {{declaration of 'x' does not match}} |
| 2661 | #endif |
| 2662 | |
| 2663 | #if defined(FIRST) |
| 2664 | struct S6 { |
| 2665 | Wrapper<int &> x; |
| 2666 | }; |
| 2667 | #elif defined(SECOND) |
| 2668 | struct S6 { |
| 2669 | Wrapper<const int &> x; |
| 2670 | }; |
| 2671 | #else |
| 2672 | S6 s6; |
| 2673 | // expected-error@first.h:* {{PointersAndReferences::S6::x' from module 'FirstModule' is not present in definition of 'PointersAndReferences::S6' in module 'SecondModule'}} |
| 2674 | // expected-note@second.h:* {{declaration of 'x' does not match}} |
| 2675 | #endif |
| 2676 | |
| 2677 | #define DECLS \ |
| 2678 | Wrapper<int *> x1; \ |
| 2679 | Wrapper<float *> x2; \ |
| 2680 | Wrapper<const float *> x3; \ |
| 2681 | Wrapper<int &> x4; \ |
| 2682 | Wrapper<int &&> x5; \ |
| 2683 | Wrapper<const int &> x6; \ |
| 2684 | Wrapper<S1 *> x7; \ |
| 2685 | Wrapper<S1 &> x8; \ |
| 2686 | Wrapper<S1 &&> x9; |
| 2687 | |
| 2688 | #if defined(FIRST) || defined(SECOND) |
| 2689 | struct Valid1 { |
| 2690 | DECLS |
| 2691 | }; |
| 2692 | #else |
| 2693 | Valid1 v1; |
| 2694 | #endif |
| 2695 | |
| 2696 | #if defined(FIRST) || defined(SECOND) |
| 2697 | struct Invalid1 { |
| 2698 | DECLS |
| 2699 | ACCESS |
| 2700 | }; |
| 2701 | #else |
| 2702 | Invalid1 i1; |
| 2703 | // expected-error@second.h:* {{'PointersAndReferences::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 2704 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 2705 | #endif |
| 2706 | #undef DECLS |
| 2707 | } // namespace PointersAndReferences |
| 2708 | |
Richard Trieu | 9359e8f | 2018-05-30 01:12:26 +0000 | [diff] [blame] | 2709 | namespace FunctionTemplate { |
| 2710 | #if defined(FIRST) |
| 2711 | struct S1 { |
| 2712 | template <int, int> void foo(); |
| 2713 | }; |
| 2714 | #elif defined(SECOND) |
| 2715 | struct S1 { |
| 2716 | template <int> void foo(); |
| 2717 | }; |
| 2718 | #else |
| 2719 | S1 s1; |
| 2720 | // expected-error@first.h:* {{'FunctionTemplate::S1::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S1' in module 'SecondModule'}} |
| 2721 | // expected-note@second.h:* {{declaration of 'foo' does not match}} |
| 2722 | #endif |
| 2723 | |
| 2724 | #if defined(FIRST) |
| 2725 | struct S2 { |
| 2726 | template <char> void foo(); |
| 2727 | }; |
| 2728 | #elif defined(SECOND) |
| 2729 | struct S2 { |
| 2730 | template <int> void foo(); |
| 2731 | }; |
| 2732 | #else |
| 2733 | S2 s2; |
| 2734 | // expected-error@first.h:* {{'FunctionTemplate::S2::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S2' in module 'SecondModule'}} |
| 2735 | // expected-note@second.h:* {{declaration of 'foo' does not match}} |
| 2736 | #endif |
| 2737 | |
| 2738 | #if defined(FIRST) |
| 2739 | struct S3 { |
| 2740 | template <int x> void foo(); |
| 2741 | }; |
| 2742 | #elif defined(SECOND) |
| 2743 | struct S3 { |
| 2744 | template <int y> void foo(); |
| 2745 | }; |
| 2746 | #else |
| 2747 | S3 s3; |
| 2748 | // expected-error@second.h:* {{'FunctionTemplate::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter named 'y'}} |
| 2749 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}} |
| 2750 | #endif |
| 2751 | |
| 2752 | #if defined(FIRST) |
| 2753 | struct S4 { |
| 2754 | template <int x> void foo(); |
| 2755 | }; |
| 2756 | #elif defined(SECOND) |
| 2757 | struct S4 { |
| 2758 | template <int x> void bar(); |
| 2759 | }; |
| 2760 | #else |
| 2761 | S4 s4; |
| 2762 | // expected-error@first.h:* {{'FunctionTemplate::S4::foo' from module 'FirstModule' is not present in definition of 'FunctionTemplate::S4' in module 'SecondModule'}} |
| 2763 | // expected-note@second.h:* {{definition has no member 'foo'}} |
| 2764 | #endif |
| 2765 | |
| 2766 | #if defined(FIRST) |
| 2767 | struct S5 { |
| 2768 | template <int x> void foo(); |
| 2769 | }; |
| 2770 | #elif defined(SECOND) |
| 2771 | struct S5 { |
| 2772 | public: |
| 2773 | template <int x> void foo(); |
| 2774 | }; |
| 2775 | #else |
| 2776 | S5 s5; |
| 2777 | // expected-error@second.h:* {{'FunctionTemplate::S5' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
| 2778 | // expected-note@first.h:* {{but in 'FirstModule' found function template}} |
| 2779 | #endif |
| 2780 | |
| 2781 | #if defined(FIRST) |
| 2782 | struct S6 { |
| 2783 | template <typename x = int> void foo(); |
| 2784 | }; |
| 2785 | #elif defined(SECOND) |
| 2786 | struct S6 { |
| 2787 | template <typename x> void foo(); |
| 2788 | }; |
| 2789 | #else |
| 2790 | S6 s6; |
| 2791 | // expected-error@second.h:* {{'FunctionTemplate::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no default argument}} |
| 2792 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}} |
| 2793 | #endif |
| 2794 | |
| 2795 | #if defined(FIRST) |
| 2796 | struct S7 { |
| 2797 | template <typename x = void> void foo(); |
| 2798 | }; |
| 2799 | #elif defined(SECOND) |
| 2800 | struct S7 { |
| 2801 | template <typename x = int> void foo(); |
| 2802 | }; |
| 2803 | #else |
| 2804 | S7 s7; |
| 2805 | // expected-error@second.h:* {{'FunctionTemplate::S7' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 'int'}} |
| 2806 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'void'}} |
| 2807 | #endif |
| 2808 | |
| 2809 | #if defined(FIRST) |
| 2810 | template <int> |
| 2811 | struct U8 {}; |
| 2812 | struct S8 { |
| 2813 | template <template<int> class x = U8> void foo(); |
| 2814 | }; |
| 2815 | #elif defined(SECOND) |
| 2816 | template <int> |
| 2817 | struct T8 {}; |
| 2818 | struct S8{ |
| 2819 | template <template<int> class x = T8> void foo(); |
| 2820 | }; |
| 2821 | #else |
| 2822 | S8 s8; |
| 2823 | // expected-error@second.h:* {{'FunctionTemplate::S8' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 'T8'}} |
| 2824 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'U8'}} |
| 2825 | #endif |
| 2826 | |
| 2827 | #if defined(FIRST) |
| 2828 | template <int> |
| 2829 | struct U9 {}; |
| 2830 | struct S9 { S9(); |
| 2831 | template <template<int> class x = U9> void foo(); |
| 2832 | }; |
| 2833 | #elif defined(SECOND) |
| 2834 | struct S9 { S9(); |
| 2835 | template <template<int> class x> void foo(); |
| 2836 | }; |
| 2837 | #else |
| 2838 | S9 s9; |
| 2839 | // expected-error@second.h:* {{'FunctionTemplate::S9' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no default argument}} |
| 2840 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}} |
| 2841 | #endif |
| 2842 | |
| 2843 | #if defined(FIRST) |
| 2844 | struct S10 { |
| 2845 | template <template<int> class x> void foo(); |
| 2846 | template <template<typename> class x> void foo(); |
| 2847 | }; |
| 2848 | #elif defined(SECOND) |
| 2849 | struct S10 { |
| 2850 | template <template<typename> class x> void foo(); |
| 2851 | template <template<int> class x> void foo(); |
| 2852 | }; |
| 2853 | #else |
| 2854 | S10 s10; |
| 2855 | // expected-error@second.h:* {{'FunctionTemplate::S10' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with one type}} |
| 2856 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}} |
| 2857 | #endif |
| 2858 | |
| 2859 | #if defined(FIRST) |
| 2860 | struct S11 { |
| 2861 | template <template<int> class x> void foo(); |
| 2862 | }; |
| 2863 | #elif defined(SECOND) |
| 2864 | struct S11 { |
| 2865 | template <template<int> class> void foo(); |
| 2866 | }; |
| 2867 | #else |
| 2868 | S11 s11; |
| 2869 | // expected-error@second.h:* {{'FunctionTemplate::S11' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no name}} |
| 2870 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter named 'x'}} |
| 2871 | #endif |
| 2872 | |
| 2873 | #if defined(FIRST) |
| 2874 | struct S12 { |
| 2875 | template <class> void foo(); |
| 2876 | template <class, class> void foo(); |
| 2877 | }; |
| 2878 | #elif defined(SECOND) |
| 2879 | struct S12 { |
| 2880 | template <class, class> void foo(); |
| 2881 | template <class> void foo(); |
| 2882 | }; |
| 2883 | #else |
| 2884 | S12 s12; |
| 2885 | // expected-error@second.h:* {{'FunctionTemplate::S12' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 2 template parameters}} |
| 2886 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1 template parameter}} |
| 2887 | #endif |
| 2888 | |
| 2889 | #if defined(FIRST) |
| 2890 | struct S13 { |
| 2891 | template <class = int> void foo(); |
| 2892 | }; |
| 2893 | #elif defined(SECOND) |
| 2894 | struct S13 { |
| 2895 | template <class = void> void foo(); |
| 2896 | }; |
| 2897 | #else |
| 2898 | S13 s13; |
| 2899 | // expected-error@second.h:* {{'FunctionTemplate::S13' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 'void'}} |
| 2900 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 'int'}} |
| 2901 | #endif |
| 2902 | |
| 2903 | #if defined(FIRST) |
| 2904 | struct S14 { |
| 2905 | template <class = void> void foo(); |
| 2906 | }; |
| 2907 | #elif defined(SECOND) |
| 2908 | struct S14 { |
| 2909 | template <class> void foo(); |
| 2910 | }; |
| 2911 | #else |
| 2912 | S14 s14; |
| 2913 | // expected-error@second.h:* {{'FunctionTemplate::S14' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with no default argument}} |
| 2914 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument}} |
| 2915 | #endif |
| 2916 | |
| 2917 | #if defined(FIRST) |
| 2918 | struct S15 { |
| 2919 | template <class> void foo(); |
| 2920 | }; |
| 2921 | #elif defined(SECOND) |
| 2922 | struct S15 { |
| 2923 | template <class = void> void foo(); |
| 2924 | }; |
| 2925 | #else |
| 2926 | S15 s15; |
| 2927 | // expected-error@second.h:* {{'FunctionTemplate::S15' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument}} |
| 2928 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}} |
| 2929 | #endif |
| 2930 | |
| 2931 | #if defined(FIRST) |
| 2932 | struct S16 { |
| 2933 | template <short> void foo(); |
| 2934 | }; |
| 2935 | #elif defined(SECOND) |
| 2936 | struct S16 { |
| 2937 | template <short = 1> void foo(); |
| 2938 | }; |
| 2939 | #else |
| 2940 | S16 s16; |
| 2941 | // expected-error@second.h:* {{'FunctionTemplate::S16' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument}} |
| 2942 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with no default argument}} |
| 2943 | #endif |
| 2944 | |
| 2945 | #if defined(FIRST) |
| 2946 | struct S17 { |
| 2947 | template <short = 2> void foo(); |
| 2948 | }; |
| 2949 | #elif defined(SECOND) |
| 2950 | struct S17 { |
| 2951 | template <short = 1 + 1> void foo(); |
| 2952 | }; |
| 2953 | #else |
| 2954 | S17 s17; |
| 2955 | // expected-error@second.h:* {{'FunctionTemplate::S17' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with default argument 1 + 1}} |
| 2956 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with default argument 2}} |
| 2957 | #endif |
| 2958 | |
| 2959 | #if defined(FIRST) |
| 2960 | struct S18 { |
| 2961 | template <short> void foo(); |
| 2962 | template <int> void foo(); |
| 2963 | }; |
| 2964 | #elif defined(SECOND) |
| 2965 | struct S18 { |
| 2966 | template <int> void foo(); |
| 2967 | template <short> void foo(); |
| 2968 | }; |
| 2969 | #else |
| 2970 | S18 s18; |
| 2971 | // expected-error@second.h:* {{'FunctionTemplate::S18' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter with one type}} |
| 2972 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter with different type}} |
| 2973 | #endif |
| 2974 | |
| 2975 | #if defined(FIRST) |
| 2976 | struct S19 { |
| 2977 | template <short> void foo(); |
| 2978 | template <short...> void foo(); |
| 2979 | }; |
| 2980 | #elif defined(SECOND) |
| 2981 | struct S19 { |
| 2982 | template <short...> void foo(); |
| 2983 | template <short> void foo(); |
| 2984 | }; |
| 2985 | #else |
| 2986 | S19 s19; |
| 2987 | // expected-error@second.h:* {{'FunctionTemplate::S19' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a template parameter pack}} |
| 2988 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}} |
| 2989 | #endif |
| 2990 | |
| 2991 | #if defined(FIRST) |
| 2992 | struct S20 { |
| 2993 | template <class> void foo(); |
| 2994 | template <class...> void foo(); |
| 2995 | }; |
| 2996 | #elif defined(SECOND) |
| 2997 | struct S20 { |
| 2998 | template <class...> void foo(); |
| 2999 | template <class> void foo(); |
| 3000 | }; |
| 3001 | #else |
| 3002 | S20 s20; |
| 3003 | // expected-error@second.h:* {{'FunctionTemplate::S20' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a template parameter pack}} |
| 3004 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter not being a template parameter pack}} |
| 3005 | #endif |
| 3006 | |
| 3007 | #if defined(FIRST) |
| 3008 | struct S21 { |
| 3009 | template <template<class> class...> void foo(); |
| 3010 | template <template<class> class> void foo(); |
| 3011 | }; |
| 3012 | #elif defined(SECOND) |
| 3013 | struct S21 { |
| 3014 | template <template<class> class> void foo(); |
| 3015 | template <template<class> class...> void foo(); |
| 3016 | }; |
| 3017 | #else |
| 3018 | S21 s21; |
| 3019 | // expected-error@second.h:* {{'FunctionTemplate::S21' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter not being a template parameter pack}} |
| 3020 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template parameter being a template parameter pack}} |
| 3021 | #endif |
| 3022 | |
| 3023 | #if defined(FIRST) |
| 3024 | struct S22 { |
| 3025 | template <template<class> class> void foo(); |
| 3026 | template <class> void foo(); |
| 3027 | template <int> void foo(); |
| 3028 | }; |
| 3029 | #elif defined(SECOND) |
| 3030 | struct S22 { |
| 3031 | template <class> void foo(); |
| 3032 | template <int> void foo(); |
| 3033 | template <template<class> class> void foo(); |
| 3034 | }; |
| 3035 | #else |
| 3036 | S22 s22; |
| 3037 | // expected-error@second.h:* {{'FunctionTemplate::S22' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a type template parameter}} |
| 3038 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a template template parameter}} |
| 3039 | #endif |
| 3040 | |
| 3041 | #if defined(FIRST) |
| 3042 | struct S23 { |
| 3043 | template <class> void foo(); |
| 3044 | template <int> void foo(); |
| 3045 | template <template<class> class> void foo(); |
| 3046 | }; |
| 3047 | #elif defined(SECOND) |
| 3048 | struct S23 { |
| 3049 | template <int> void foo(); |
| 3050 | template <template<class> class> void foo(); |
| 3051 | template <class> void foo(); |
| 3052 | }; |
| 3053 | #else |
| 3054 | S23 s23; |
| 3055 | // expected-error@second.h:* {{'FunctionTemplate::S23' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a non-type template parameter}} |
| 3056 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a type template parameter}} |
| 3057 | #endif |
| 3058 | |
| 3059 | #if defined(FIRST) |
| 3060 | struct S24 { |
| 3061 | template <int> void foo(); |
| 3062 | template <template<class> class> void foo(); |
| 3063 | template <class> void foo(); |
| 3064 | }; |
| 3065 | #elif defined(SECOND) |
| 3066 | struct S24 { |
| 3067 | template <template<class> class> void foo(); |
| 3068 | template <class> void foo(); |
| 3069 | template <int> void foo(); |
| 3070 | }; |
| 3071 | #else |
| 3072 | S24 s24; |
| 3073 | // expected-error@second.h:* {{'FunctionTemplate::S24' has different definitions in different modules; first difference is definition in module 'SecondModule' found function template 'foo' with 1st template parameter being a template template parameter}} |
| 3074 | // expected-note@first.h:* {{but in 'FirstModule' found function template 'foo' with 1st template paramter being a non-type template parameter}} |
| 3075 | #endif |
| 3076 | |
| 3077 | #if defined(FIRST) |
| 3078 | struct S25 { |
| 3079 | template <int> void foo(); |
| 3080 | }; |
| 3081 | #elif defined(SECOND) |
| 3082 | struct S25 { |
| 3083 | public: |
| 3084 | template <int> void foo(); |
| 3085 | }; |
| 3086 | #else |
| 3087 | S25 s25; |
| 3088 | // expected-error@second.h:* {{'FunctionTemplate::S25' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
| 3089 | // expected-note@first.h:* {{but in 'FirstModule' found function template}} |
| 3090 | #endif |
| 3091 | |
| 3092 | #define DECLS \ |
| 3093 | template <int> \ |
| 3094 | void nontype1(); \ |
| 3095 | template <int x> \ |
| 3096 | void nontype2(); \ |
| 3097 | template <int, int> \ |
| 3098 | void nontype3(); \ |
| 3099 | template <int x = 5> \ |
| 3100 | void nontype4(); \ |
| 3101 | template <int... x> \ |
| 3102 | void nontype5(); \ |
| 3103 | \ |
| 3104 | template <class> \ |
| 3105 | void type1(); \ |
| 3106 | template <class x> \ |
| 3107 | void type2(); \ |
| 3108 | template <class, class> \ |
| 3109 | void type3(); \ |
| 3110 | template <class x = int> \ |
| 3111 | void type4(); \ |
| 3112 | template <class... x> \ |
| 3113 | void type5(); \ |
| 3114 | \ |
| 3115 | template <template <int> class> \ |
| 3116 | void template1(); \ |
| 3117 | template <template <int> class x> \ |
| 3118 | void template2(); \ |
| 3119 | template <template <int> class, template <int> class> \ |
| 3120 | void template3(); \ |
| 3121 | template <template <int> class x = U> \ |
| 3122 | void template4(); \ |
| 3123 | template <template <int> class... x> \ |
| 3124 | void template5(); |
| 3125 | |
| 3126 | #if defined(FIRST) || defined(SECOND) |
| 3127 | template<int> |
| 3128 | struct U {}; |
| 3129 | struct Valid1 { |
| 3130 | DECLS |
| 3131 | }; |
| 3132 | #else |
| 3133 | Valid1 v1; |
| 3134 | #endif |
| 3135 | |
| 3136 | #if defined(FIRST) || defined(SECOND) |
| 3137 | struct Invalid1 { |
| 3138 | DECLS |
| 3139 | ACCESS |
| 3140 | }; |
| 3141 | #else |
| 3142 | Invalid1 i1; |
| 3143 | // expected-error@second.h:* {{'FunctionTemplate::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 3144 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 3145 | #endif |
| 3146 | #undef DECLS |
| 3147 | } |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3148 | |
| 3149 | // Collection of interesting cases below. |
| 3150 | |
| 3151 | // Naive parsing of AST can lead to cycles in processing. Ensure |
| 3152 | // self-references don't trigger an endless cycles of AST node processing. |
| 3153 | namespace SelfReference { |
| 3154 | #if defined(FIRST) |
| 3155 | template <template <int> class T> class Wrapper {}; |
| 3156 | |
| 3157 | template <int N> class S { |
| 3158 | S(Wrapper<::SelfReference::S> &Ref) {} |
| 3159 | }; |
| 3160 | |
| 3161 | struct Xx { |
| 3162 | struct Yy { |
Richard Trieu | fe56405 | 2017-04-20 02:53:53 +0000 | [diff] [blame] | 3163 | }; |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3164 | }; |
Richard Trieu | fe56405 | 2017-04-20 02:53:53 +0000 | [diff] [blame] | 3165 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3166 | Xx::Xx::Xx::Yy yy; |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 3167 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3168 | namespace NNS { |
| 3169 | template <typename> struct Foo; |
| 3170 | template <template <class> class T = NNS::Foo> |
| 3171 | struct NestedNamespaceSpecifier {}; |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 3172 | } |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3173 | #endif |
| 3174 | } // namespace SelfReference |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 3175 | |
| 3176 | namespace FriendFunction { |
| 3177 | #if defined(FIRST) |
| 3178 | void F(int = 0); |
| 3179 | struct S { friend void F(int); }; |
| 3180 | #elif defined(SECOND) |
| 3181 | void F(int); |
| 3182 | struct S { friend void F(int); }; |
| 3183 | #else |
| 3184 | S s; |
| 3185 | #endif |
| 3186 | |
| 3187 | #if defined(FIRST) |
| 3188 | void G(int = 0); |
| 3189 | struct T { |
| 3190 | friend void G(int); |
| 3191 | |
| 3192 | private: |
| 3193 | }; |
| 3194 | #elif defined(SECOND) |
| 3195 | void G(int); |
| 3196 | struct T { |
| 3197 | friend void G(int); |
| 3198 | |
| 3199 | public: |
| 3200 | }; |
| 3201 | #else |
| 3202 | T t; |
| 3203 | // expected-error@second.h:* {{'FriendFunction::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
| 3204 | // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}} |
| 3205 | #endif |
| 3206 | } // namespace FriendFunction |
| 3207 | |
| 3208 | namespace ImplicitDecl { |
| 3209 | #if defined(FIRST) |
| 3210 | struct S { }; |
| 3211 | void S_Constructors() { |
| 3212 | // Trigger creation of implicit contructors |
| 3213 | S foo; |
| 3214 | S bar = foo; |
| 3215 | S baz(bar); |
| 3216 | } |
| 3217 | #elif defined(SECOND) |
| 3218 | struct S { }; |
| 3219 | #else |
| 3220 | S s; |
| 3221 | #endif |
| 3222 | |
| 3223 | #if defined(FIRST) |
| 3224 | struct T { |
| 3225 | private: |
| 3226 | }; |
| 3227 | void T_Constructors() { |
| 3228 | // Trigger creation of implicit contructors |
| 3229 | T foo; |
| 3230 | T bar = foo; |
| 3231 | T baz(bar); |
| 3232 | } |
| 3233 | #elif defined(SECOND) |
| 3234 | struct T { |
| 3235 | public: |
| 3236 | }; |
| 3237 | #else |
| 3238 | T t; |
| 3239 | // expected-error@first.h:* {{'ImplicitDecl::T' has different definitions in different modules; first difference is definition in module 'FirstModule' found private access specifier}} |
| 3240 | // expected-note@second.h:* {{but in 'SecondModule' found public access specifier}} |
| 3241 | #endif |
| 3242 | |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3243 | } // namespace ImplicitDecl |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 3244 | |
| 3245 | namespace TemplatedClass { |
| 3246 | #if defined(FIRST) |
| 3247 | template <class> |
| 3248 | struct S {}; |
| 3249 | #elif defined(SECOND) |
| 3250 | template <class> |
| 3251 | struct S {}; |
| 3252 | #else |
| 3253 | S<int> s; |
| 3254 | #endif |
| 3255 | |
| 3256 | #if defined(FIRST) |
| 3257 | template <class> |
| 3258 | struct T { |
| 3259 | private: |
| 3260 | }; |
| 3261 | #elif defined(SECOND) |
| 3262 | template <class> |
| 3263 | struct T { |
| 3264 | public: |
| 3265 | }; |
| 3266 | #else |
| 3267 | T<int> t; |
| 3268 | // expected-error@second.h:* {{'TemplatedClass::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
| 3269 | // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}} |
| 3270 | #endif |
| 3271 | } // namespace TemplatedClass |
| 3272 | |
| 3273 | namespace TemplateClassWithField { |
| 3274 | #if defined(FIRST) |
| 3275 | template <class A> |
| 3276 | struct S { |
| 3277 | A a; |
| 3278 | }; |
| 3279 | #elif defined(SECOND) |
| 3280 | template <class A> |
| 3281 | struct S { |
| 3282 | A a; |
| 3283 | }; |
| 3284 | #else |
| 3285 | S<int> s; |
| 3286 | #endif |
| 3287 | |
| 3288 | #if defined(FIRST) |
| 3289 | template <class A> |
| 3290 | struct T { |
| 3291 | A a; |
| 3292 | |
| 3293 | private: |
| 3294 | }; |
| 3295 | #elif defined(SECOND) |
| 3296 | template <class A> |
| 3297 | struct T { |
| 3298 | A a; |
| 3299 | |
| 3300 | public: |
| 3301 | }; |
| 3302 | #else |
| 3303 | T<int> t; |
| 3304 | // expected-error@second.h:* {{'TemplateClassWithField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found public access specifier}} |
| 3305 | // expected-note@first.h:* {{but in 'FirstModule' found private access specifier}} |
| 3306 | #endif |
| 3307 | } // namespace TemplateClassWithField |
| 3308 | |
| 3309 | namespace TemplateClassWithTemplateField { |
| 3310 | #if defined(FIRST) |
| 3311 | template <class A> |
| 3312 | class WrapperS; |
| 3313 | template <class A> |
| 3314 | struct S { |
| 3315 | WrapperS<A> a; |
| 3316 | }; |
| 3317 | #elif defined(SECOND) |
| 3318 | template <class A> |
| 3319 | class WrapperS; |
| 3320 | template <class A> |
| 3321 | struct S { |
| 3322 | WrapperS<A> a; |
| 3323 | }; |
| 3324 | #else |
| 3325 | template <class A> |
| 3326 | class WrapperS{}; |
| 3327 | S<int> s; |
| 3328 | #endif |
| 3329 | |
| 3330 | #if defined(FIRST) |
| 3331 | template <class A> |
| 3332 | class WrapperT; |
| 3333 | template <class A> |
| 3334 | struct T { |
| 3335 | WrapperT<A> a; |
| 3336 | |
| 3337 | public: |
| 3338 | }; |
| 3339 | #elif defined(SECOND) |
| 3340 | template <class A> |
| 3341 | class WrapperT; |
| 3342 | template <class A> |
| 3343 | struct T { |
| 3344 | WrapperT<A> a; |
| 3345 | |
| 3346 | private: |
| 3347 | }; |
| 3348 | #else |
| 3349 | template <class A> |
| 3350 | class WrapperT{}; |
| 3351 | T<int> t; |
| 3352 | // expected-error@second.h:* {{'TemplateClassWithTemplateField::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 3353 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 3354 | #endif |
| 3355 | } // namespace TemplateClassWithTemplateField |
| 3356 | |
| 3357 | namespace EnumWithForwardDeclaration { |
| 3358 | #if defined(FIRST) |
| 3359 | enum E : int; |
| 3360 | struct S { |
| 3361 | void get(E) {} |
| 3362 | }; |
| 3363 | #elif defined(SECOND) |
| 3364 | enum E : int { A, B }; |
| 3365 | struct S { |
| 3366 | void get(E) {} |
| 3367 | }; |
| 3368 | #else |
| 3369 | S s; |
| 3370 | #endif |
| 3371 | |
| 3372 | #if defined(FIRST) |
| 3373 | struct T { |
| 3374 | void get(E) {} |
| 3375 | public: |
| 3376 | }; |
| 3377 | #elif defined(SECOND) |
| 3378 | struct T { |
| 3379 | void get(E) {} |
| 3380 | private: |
| 3381 | }; |
| 3382 | #else |
| 3383 | T t; |
| 3384 | // expected-error@second.h:* {{'EnumWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 3385 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 3386 | #endif |
| 3387 | } // namespace EnumWithForwardDeclaration |
| 3388 | |
| 3389 | namespace StructWithForwardDeclaration { |
| 3390 | #if defined(FIRST) |
| 3391 | struct P {}; |
| 3392 | struct S { |
| 3393 | struct P *ptr; |
| 3394 | }; |
| 3395 | #elif defined(SECOND) |
| 3396 | struct S { |
| 3397 | struct P *ptr; |
| 3398 | }; |
| 3399 | #else |
| 3400 | S s; |
| 3401 | #endif |
| 3402 | |
| 3403 | #if defined(FIRST) |
| 3404 | struct Q {}; |
| 3405 | struct T { |
| 3406 | struct Q *ptr; |
| 3407 | public: |
| 3408 | }; |
| 3409 | #elif defined(SECOND) |
| 3410 | struct T { |
| 3411 | struct Q *ptr; |
| 3412 | private: |
| 3413 | }; |
| 3414 | #else |
| 3415 | T t; |
| 3416 | // expected-error@second.h:* {{'StructWithForwardDeclaration::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 3417 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 3418 | #endif |
| 3419 | } // namespace StructWithForwardDeclaration |
| 3420 | |
| 3421 | namespace StructWithForwardDeclarationNoDefinition { |
| 3422 | #if defined(FIRST) |
| 3423 | struct P; |
| 3424 | struct S { |
| 3425 | struct P *ptr; |
| 3426 | }; |
| 3427 | #elif defined(SECOND) |
| 3428 | struct S { |
| 3429 | struct P *ptr; |
| 3430 | }; |
| 3431 | #else |
| 3432 | S s; |
| 3433 | #endif |
| 3434 | |
| 3435 | #if defined(FIRST) |
| 3436 | struct Q; |
| 3437 | struct T { |
| 3438 | struct Q *ptr; |
| 3439 | |
| 3440 | public: |
| 3441 | }; |
| 3442 | #elif defined(SECOND) |
| 3443 | struct T { |
| 3444 | struct Q *ptr; |
| 3445 | |
| 3446 | private: |
| 3447 | }; |
| 3448 | #else |
| 3449 | T t; |
| 3450 | // expected-error@second.h:* {{'StructWithForwardDeclarationNoDefinition::T' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}} |
| 3451 | // expected-note@first.h:* {{but in 'FirstModule' found public access specifier}} |
| 3452 | #endif |
| 3453 | } // namespace StructWithForwardDeclarationNoDefinition |
| 3454 | |
Richard Trieu | fe56405 | 2017-04-20 02:53:53 +0000 | [diff] [blame] | 3455 | namespace LateParsedDefaultArgument { |
| 3456 | #if defined(FIRST) |
| 3457 | template <typename T> |
| 3458 | struct S { |
| 3459 | struct R { |
| 3460 | void foo(T x = 0) {} |
| 3461 | }; |
| 3462 | }; |
| 3463 | #elif defined(SECOND) |
| 3464 | #else |
| 3465 | void run() { |
| 3466 | S<int>::R().foo(); |
| 3467 | } |
| 3468 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3469 | } // namespace LateParsedDefaultArgument |
Richard Trieu | fe56405 | 2017-04-20 02:53:53 +0000 | [diff] [blame] | 3470 | |
| 3471 | namespace LateParsedDefaultArgument { |
| 3472 | #if defined(FIRST) |
| 3473 | template <typename alpha> struct Bravo { |
| 3474 | void charlie(bool delta = false) {} |
| 3475 | }; |
| 3476 | typedef Bravo<char> echo; |
| 3477 | echo foxtrot; |
| 3478 | |
| 3479 | Bravo<char> golf; |
| 3480 | #elif defined(SECOND) |
| 3481 | #else |
| 3482 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3483 | } // LateParsedDefaultArgument |
Richard Trieu | fe56405 | 2017-04-20 02:53:53 +0000 | [diff] [blame] | 3484 | |
Richard Trieu | 157ed94 | 2017-04-28 22:03:28 +0000 | [diff] [blame] | 3485 | namespace DifferentParameterNameInTemplate { |
| 3486 | #if defined(FIRST) || defined(SECOND) |
| 3487 | template <typename T> |
| 3488 | struct S { |
| 3489 | typedef T Type; |
| 3490 | |
| 3491 | static void Run(const Type *name_one); |
| 3492 | }; |
| 3493 | |
| 3494 | template <typename T> |
| 3495 | void S<T>::Run(const T *name_two) {} |
| 3496 | |
| 3497 | template <typename T> |
| 3498 | struct Foo { |
| 3499 | ~Foo() { Handler::Run(nullptr); } |
| 3500 | Foo() {} |
| 3501 | |
| 3502 | class Handler : public S<T> {}; |
| 3503 | |
| 3504 | void Get(typename Handler::Type *x = nullptr) {} |
| 3505 | void Add() { Handler::Run(nullptr); } |
| 3506 | }; |
| 3507 | #endif |
| 3508 | |
| 3509 | #if defined(FIRST) |
| 3510 | struct Beta; |
| 3511 | |
| 3512 | struct Alpha { |
| 3513 | Alpha(); |
| 3514 | void Go() { betas.Get(); } |
| 3515 | Foo<Beta> betas; |
| 3516 | }; |
| 3517 | |
| 3518 | #elif defined(SECOND) |
| 3519 | struct Beta {}; |
| 3520 | |
| 3521 | struct BetaHelper { |
| 3522 | void add_Beta() { betas.Add(); } |
| 3523 | Foo<Beta> betas; |
| 3524 | }; |
| 3525 | |
| 3526 | #else |
| 3527 | Alpha::Alpha() {} |
| 3528 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3529 | } // DifferentParameterNameInTemplate |
Richard Trieu | 157ed94 | 2017-04-28 22:03:28 +0000 | [diff] [blame] | 3530 | |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 3531 | namespace ParameterTest { |
| 3532 | #if defined(FIRST) |
| 3533 | class X {}; |
| 3534 | template <typename G> |
| 3535 | class S { |
| 3536 | public: |
| 3537 | typedef G Type; |
| 3538 | static inline G *Foo(const G *a, int * = nullptr); |
| 3539 | }; |
| 3540 | |
| 3541 | template<typename G> |
| 3542 | G* S<G>::Foo(const G* aaaa, int*) {} |
| 3543 | #elif defined(SECOND) |
| 3544 | template <typename G> |
| 3545 | class S { |
| 3546 | public: |
| 3547 | typedef G Type; |
| 3548 | static inline G *Foo(const G *a, int * = nullptr); |
| 3549 | }; |
| 3550 | |
| 3551 | template<typename G> |
| 3552 | G* S<G>::Foo(const G* asdf, int*) {} |
| 3553 | #else |
| 3554 | S<X> s; |
| 3555 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3556 | } // ParameterTest |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 3557 | |
Richard Trieu | b35ef2a | 2017-05-09 03:24:34 +0000 | [diff] [blame] | 3558 | namespace MultipleTypedefs { |
| 3559 | #if defined(FIRST) |
| 3560 | typedef int B1; |
| 3561 | typedef B1 A1; |
| 3562 | struct S1 { |
| 3563 | A1 x; |
| 3564 | }; |
| 3565 | #elif defined(SECOND) |
| 3566 | typedef int A1; |
| 3567 | struct S1 { |
| 3568 | A1 x; |
| 3569 | }; |
| 3570 | #else |
| 3571 | S1 s1; |
| 3572 | #endif |
| 3573 | |
| 3574 | #if defined(FIRST) |
| 3575 | struct T2 { int x; }; |
| 3576 | typedef T2 B2; |
| 3577 | typedef B2 A2; |
| 3578 | struct S2 { |
| 3579 | T2 x; |
| 3580 | }; |
| 3581 | #elif defined(SECOND) |
| 3582 | struct T2 { int x; }; |
| 3583 | typedef T2 A2; |
| 3584 | struct S2 { |
| 3585 | T2 x; |
| 3586 | }; |
| 3587 | #else |
| 3588 | S2 s2; |
| 3589 | #endif |
Richard Trieu | 3e03d3e | 2017-06-29 22:53:04 +0000 | [diff] [blame] | 3590 | |
| 3591 | #if defined(FIRST) |
| 3592 | using A3 = const int; |
| 3593 | using B3 = volatile A3; |
| 3594 | struct S3 { |
| 3595 | B3 x = 1; |
| 3596 | }; |
| 3597 | #elif defined(SECOND) |
| 3598 | using A3 = volatile const int; |
| 3599 | using B3 = A3; |
| 3600 | struct S3 { |
| 3601 | B3 x = 1; |
| 3602 | }; |
| 3603 | #else |
| 3604 | S3 s3; |
| 3605 | #endif |
Richard Trieu | caaccee | 2018-04-12 02:26:49 +0000 | [diff] [blame] | 3606 | |
| 3607 | #if defined(FIRST) |
| 3608 | using A4 = int; |
| 3609 | using B4 = A4; |
| 3610 | struct S4 { |
| 3611 | B4 x; |
| 3612 | }; |
| 3613 | #elif defined(SECOND) |
| 3614 | using A4 = int; |
| 3615 | using B4 = ::MultipleTypedefs::A4; |
| 3616 | struct S4 { |
| 3617 | B4 x; |
| 3618 | }; |
| 3619 | #else |
| 3620 | S4 s4; |
| 3621 | #endif |
| 3622 | |
| 3623 | #if defined(FIRST) |
| 3624 | using A5 = int; |
| 3625 | using B5 = MultipleTypedefs::A5; |
| 3626 | struct S5 { |
| 3627 | B5 x; |
| 3628 | }; |
| 3629 | #elif defined(SECOND) |
| 3630 | using A5 = int; |
| 3631 | using B5 = ::MultipleTypedefs::A5; |
| 3632 | struct S5 { |
| 3633 | B5 x; |
| 3634 | }; |
| 3635 | #else |
| 3636 | S5 s5; |
| 3637 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3638 | } // MultipleTypedefs |
| 3639 | |
| 3640 | namespace DefaultArguments { |
| 3641 | #if defined(FIRST) |
| 3642 | template <typename T> |
| 3643 | struct S { |
| 3644 | struct R { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 3645 | void foo(T x = 0); |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3646 | }; |
| 3647 | }; |
| 3648 | #elif defined(SECOND) |
| 3649 | template <typename T> |
| 3650 | struct S { |
| 3651 | struct R { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 3652 | void foo(T x = 1); |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3653 | }; |
| 3654 | }; |
| 3655 | #else |
| 3656 | void run() { |
| 3657 | S<int>::R().foo(); |
Richard Trieu | b35ef2a | 2017-05-09 03:24:34 +0000 | [diff] [blame] | 3658 | } |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3659 | // expected-error@second.h:* {{'DefaultArguments::S::R' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'foo' with 1st parameter with a default argument}} |
| 3660 | // expected-note@first.h:* {{but in 'FirstModule' found method 'foo' with 1st parameter with a different default argument}} |
| 3661 | #endif |
| 3662 | |
| 3663 | #if defined(FIRST) |
| 3664 | template <typename alpha> struct Bravo { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 3665 | void charlie(bool delta = false); |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3666 | }; |
| 3667 | typedef Bravo<char> echo; |
| 3668 | echo foxtrot; |
| 3669 | #elif defined(SECOND) |
| 3670 | template <typename alpha> struct Bravo { |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 3671 | void charlie(bool delta = (false)); |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3672 | }; |
| 3673 | typedef Bravo<char> echo; |
| 3674 | echo foxtrot; |
| 3675 | #else |
| 3676 | Bravo<char> golf; |
| 3677 | // expected-error@second.h:* {{'DefaultArguments::Bravo' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'charlie' with 1st parameter with a default argument}} |
| 3678 | // expected-note@first.h:* {{but in 'FirstModule' found method 'charlie' with 1st parameter with a different default argument}} |
| 3679 | #endif |
| 3680 | } // namespace DefaultArguments |
Richard Trieu | 0255227 | 2017-05-02 23:58:52 +0000 | [diff] [blame] | 3681 | |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 3682 | namespace FunctionDecl { |
| 3683 | #if defined(FIRST) |
| 3684 | struct S1 {}; |
| 3685 | S1 s1a; |
| 3686 | #elif defined(SECOND) |
| 3687 | struct S1 {}; |
| 3688 | #else |
| 3689 | S1 s1; |
| 3690 | #endif |
| 3691 | |
| 3692 | #if defined(FIRST) |
| 3693 | struct S2 { |
| 3694 | S2() = default; |
| 3695 | }; |
| 3696 | S2 s2a = S2(); |
| 3697 | #elif defined(SECOND) |
| 3698 | struct S2 { |
| 3699 | S2() = default; |
| 3700 | }; |
| 3701 | #else |
| 3702 | S2 s2; |
| 3703 | #endif |
| 3704 | |
| 3705 | #if defined(FIRST) |
| 3706 | struct S3 { |
| 3707 | S3() = delete; |
| 3708 | }; |
| 3709 | S3* s3c; |
| 3710 | #elif defined(SECOND) |
| 3711 | struct S3 { |
| 3712 | S3() = delete; |
| 3713 | }; |
| 3714 | #else |
| 3715 | S3* s3; |
| 3716 | #endif |
| 3717 | |
| 3718 | #if defined(FIRST) || defined(SECOND) |
| 3719 | int F1(int x, float y = 2.7) { return 1; } |
| 3720 | #else |
| 3721 | int I1 = F1(1); |
| 3722 | #endif |
| 3723 | |
| 3724 | #if defined(FIRST) |
| 3725 | int F2() { return 1; } |
| 3726 | #elif defined(SECOND) |
| 3727 | double F2() { return 1; } |
| 3728 | #else |
| 3729 | int I2 = F2(); |
| 3730 | // expected-error@-1 {{call to 'F2' is ambiguous}} |
| 3731 | // expected-note@first.h:* {{candidate function}} |
| 3732 | // expected-note@second.h:* {{candidate function}} |
| 3733 | #endif |
| 3734 | |
| 3735 | #if defined(FIRST) |
| 3736 | int F3(float) { return 1; } |
| 3737 | #elif defined(SECOND) |
| 3738 | int F3(double) { return 1; } |
| 3739 | #else |
| 3740 | int I3 = F3(1); |
| 3741 | // expected-error@-1 {{call to 'F3' is ambiguous}} |
| 3742 | // expected-note@first.h:* {{candidate function}} |
| 3743 | // expected-note@second.h:* {{candidate function}} |
| 3744 | #endif |
| 3745 | |
| 3746 | #if defined(FIRST) |
| 3747 | int F4(int x) { return 1; } |
| 3748 | #elif defined(SECOND) |
| 3749 | int F4(int y) { return 1; } |
| 3750 | #else |
| 3751 | int I4 = F4(1); |
| 3752 | // expected-error@second.h:* {{'FunctionDecl::F4' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with name 'y'}} |
| 3753 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with name 'x'}} |
| 3754 | #endif |
| 3755 | |
| 3756 | #if defined(FIRST) |
| 3757 | int F5(int x) { return 1; } |
| 3758 | #elif defined(SECOND) |
| 3759 | int F5(int x = 1) { return 1; } |
| 3760 | #else |
| 3761 | int I5 = F6(1); |
| 3762 | // expected-error@second.h:* {{'FunctionDecl::F5' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter without a default argument}} |
| 3763 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a default argument}} |
| 3764 | #endif |
| 3765 | |
| 3766 | #if defined(FIRST) |
| 3767 | int F6(int x = 2) { return 1; } |
| 3768 | #elif defined(SECOND) |
| 3769 | int F6(int x = 1) { return 1; } |
| 3770 | #else |
| 3771 | int I6 = F6(1); |
| 3772 | // expected-error@second.h:* {{'FunctionDecl::F6' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with a default argument}} |
| 3773 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with a different default argument}} |
| 3774 | #endif |
| 3775 | |
| 3776 | using I = int; |
| 3777 | #if defined(FIRST) |
| 3778 | I F7() { return 0; } |
| 3779 | #elif defined(SECOND) |
| 3780 | int F7() { return 0; } |
| 3781 | #else |
| 3782 | int I7 = F7(); |
| 3783 | // expected-error@second.h:* {{'FunctionDecl::F7' has different definitions in different modules; definition in module 'SecondModule' first difference is return type is 'int'}} |
| 3784 | // expected-note@first.h:* {{but in 'FirstModule' found different return type 'FunctionDecl::I' (aka 'int')}} |
| 3785 | #endif |
| 3786 | |
| 3787 | #if defined(FIRST) |
| 3788 | int F8(int) { return 0; } |
| 3789 | #elif defined(SECOND) |
| 3790 | int F8(I) { return 0; } |
| 3791 | #else |
| 3792 | int I8 = F8(1); |
| 3793 | // expected-error@second.h:* {{'FunctionDecl::F8' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with type 'FunctionDecl::I' (aka 'int')}} |
| 3794 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int'}} |
| 3795 | #endif |
| 3796 | |
| 3797 | #if defined(FIRST) |
| 3798 | int F9(int[1]) { return 0; } |
| 3799 | #elif defined(SECOND) |
| 3800 | int F9(int[2]) { return 0; } |
| 3801 | #else |
| 3802 | int I9 = F9(nullptr); |
| 3803 | // expected-error@second.h:* {{'FunctionDecl::F9' has different definitions in different modules; definition in module 'SecondModule' first difference is 1st parameter with type 'int *' decayed from 'int [2]'}} |
| 3804 | // expected-note@first.h:* {{but in 'FirstModule' found 1st parameter with type 'int *' decayed from 'int [1]'}} |
| 3805 | #endif |
| 3806 | |
| 3807 | #if defined(FIRST) |
| 3808 | int F10() { return 1; } |
| 3809 | #elif defined(SECOND) |
| 3810 | int F10() { return 2; } |
| 3811 | #else |
| 3812 | int I10 = F10(); |
| 3813 | #endif |
| 3814 | // expected-error@second.h:* {{'FunctionDecl::F10' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
| 3815 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
Richard Trieu | 5d01406 | 2018-06-07 00:20:58 +0000 | [diff] [blame] | 3816 | |
| 3817 | #if defined(FIRST) |
| 3818 | struct S11 { |
| 3819 | template <int> void foo(); |
| 3820 | }; |
| 3821 | #elif defined(SECOND) |
| 3822 | struct S11 { |
| 3823 | template <int> void foo(); |
| 3824 | }; |
| 3825 | template <int> void S11::foo() {} |
| 3826 | #else |
| 3827 | S11 s11; |
| 3828 | #endif |
| 3829 | |
Richard Trieu | 27c1b1a | 2018-07-10 01:40:50 +0000 | [diff] [blame^] | 3830 | #if defined(FIRST) |
| 3831 | struct S12 { |
| 3832 | void foo(int x); |
| 3833 | }; |
| 3834 | #elif defined(SECOND) |
| 3835 | struct S12 { |
| 3836 | void foo(int x); |
| 3837 | }; |
| 3838 | void S12::foo(int y) {} |
| 3839 | #else |
| 3840 | S12 s12; |
| 3841 | #endif |
| 3842 | |
| 3843 | #if defined(FIRST) |
| 3844 | struct S13 { |
| 3845 | void foo(int x); |
| 3846 | }; |
| 3847 | void S13::foo(int y) {} |
| 3848 | #elif defined(SECOND) |
| 3849 | struct S13 { |
| 3850 | void foo(int x); |
| 3851 | }; |
| 3852 | void S13::foo(int y) {} |
| 3853 | #else |
| 3854 | S13 s13; |
| 3855 | #endif |
Richard Trieu | e6caa26 | 2017-12-23 00:41:01 +0000 | [diff] [blame] | 3856 | } // namespace FunctionDecl |
| 3857 | |
Richard Trieu | 4d06bef | 2018-02-13 19:53:40 +0000 | [diff] [blame] | 3858 | namespace DeclTemplateArguments { |
| 3859 | #if defined(FIRST) |
| 3860 | int foo() { return 1; } |
| 3861 | int bar() { return foo(); } |
| 3862 | #elif defined(SECOND) |
| 3863 | template <class T = int> |
| 3864 | int foo() { return 2; } |
| 3865 | int bar() { return foo<>(); } |
| 3866 | #else |
| 3867 | int num = bar(); |
| 3868 | // expected-error@second.h:* {{'DeclTemplateArguments::bar' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}} |
| 3869 | // expected-note@first.h:* {{but in 'FirstModule' found a different body}} |
| 3870 | #endif |
| 3871 | } |
| 3872 | |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 3873 | // Keep macros contained to one file. |
| 3874 | #ifdef FIRST |
| 3875 | #undef FIRST |
| 3876 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3877 | |
Richard Trieu | e7f7ed2 | 2017-02-22 01:11:25 +0000 | [diff] [blame] | 3878 | #ifdef SECOND |
| 3879 | #undef SECOND |
| 3880 | #endif |
Richard Trieu | 73cf924 | 2017-11-04 01:20:50 +0000 | [diff] [blame] | 3881 | |
| 3882 | #ifdef ACCESS |
| 3883 | #undef ACCESS |
| 3884 | #endif |