Chris Lattner | 285d03f | 2009-04-11 20:52:19 +0000 | [diff] [blame] | 1 | // Test this without pch. |
Argyrios Kyrtzidis | b73377e | 2011-07-07 03:40:34 +0000 | [diff] [blame^] | 2 | // RUN: %clang_cc1 -include %s -fsyntax-only -verify %s |
Chris Lattner | 285d03f | 2009-04-11 20:52:19 +0000 | [diff] [blame] | 3 | |
| 4 | // Test with pch. |
Argyrios Kyrtzidis | b73377e | 2011-07-07 03:40:34 +0000 | [diff] [blame^] | 5 | // RUN: %clang_cc1 -emit-pch -o %t %s |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 6 | // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s |
Douglas Gregor | 2cf2634 | 2009-04-09 22:27:44 +0000 | [diff] [blame] | 7 | |
Argyrios Kyrtzidis | b73377e | 2011-07-07 03:40:34 +0000 | [diff] [blame^] | 8 | #ifndef HEADER |
| 9 | #define HEADER |
| 10 | |
| 11 | extern float y; |
| 12 | extern int *ip, x; |
| 13 | |
| 14 | float z; // expected-note{{previous}} |
| 15 | |
| 16 | int z2 = 17; // expected-note{{previous}} |
| 17 | |
| 18 | #define MAKE_HAPPY(X) X##Happy |
| 19 | int MAKE_HAPPY(Very); // expected-note{{previous definition is here}} |
| 20 | |
| 21 | #define A_MACRO_IN_THE_PCH 492 |
| 22 | #define FUNCLIKE_MACRO(X, Y) X ## Y |
| 23 | |
| 24 | #define PASTE2(x,y) x##y |
| 25 | #define PASTE1(x,y) PASTE2(x,y) |
| 26 | #define UNIQUE(x) PASTE1(x,__COUNTER__) |
| 27 | |
| 28 | int UNIQUE(a); // a0 |
| 29 | int UNIQUE(a); // a1 |
| 30 | |
| 31 | #else |
| 32 | |
Douglas Gregor | 2cf2634 | 2009-04-09 22:27:44 +0000 | [diff] [blame] | 33 | int *ip2 = &x; |
| 34 | float *fp = &ip; // expected-warning{{incompatible pointer types}} |
Douglas Gregor | 14f7900 | 2009-04-10 03:52:48 +0000 | [diff] [blame] | 35 | double z; // expected-error{{redefinition}} |
Douglas Gregor | 0b74891 | 2009-04-14 21:18:50 +0000 | [diff] [blame] | 36 | int z2 = 18; // expected-error{{redefinition}} |
Douglas Gregor | 0c8c455 | 2009-04-22 00:17:41 +0000 | [diff] [blame] | 37 | double VeryHappy; // expected-error{{redefinition}} |
Chris Lattner | 531cc83 | 2009-04-10 22:13:17 +0000 | [diff] [blame] | 38 | |
| 39 | int Q = A_MACRO_IN_THE_PCH; |
| 40 | |
Chris Lattner | c1f9d82 | 2009-04-13 01:29:17 +0000 | [diff] [blame] | 41 | int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH); |
| 42 | |
| 43 | |
| 44 | int UNIQUE(a); // a2 |
| 45 | int *Arr[] = { &a0, &a1, &a2 }; |
Argyrios Kyrtzidis | b73377e | 2011-07-07 03:40:34 +0000 | [diff] [blame^] | 46 | |
| 47 | #endif |