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 | |
Jordan Rose | 78541c4 | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 14 | float z; |
Argyrios Kyrtzidis | b73377e | 2011-07-07 03:40:34 +0000 | [diff] [blame] | 15 | |
Jordan Rose | 78541c4 | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 16 | int z2 = 17; |
Argyrios Kyrtzidis | b73377e | 2011-07-07 03:40:34 +0000 | [diff] [blame] | 17 | |
| 18 | #define MAKE_HAPPY(X) X##Happy |
Jordan Rose | 78541c4 | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 19 | int MAKE_HAPPY(Very); |
Argyrios Kyrtzidis | b73377e | 2011-07-07 03:40:34 +0000 | [diff] [blame] | 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}} |
Jordan Rose | 78541c4 | 2012-07-11 19:58:23 +0000 | [diff] [blame] | 35 | double z; // expected-error{{redefinition}} expected-note@14{{previous}} |
| 36 | int z2 = 18; // expected-error{{redefinition}} expected-note@16{{previous}} |
| 37 | double VeryHappy; // expected-error{{redefinition}} expected-note@19{{previous definition is here}} |
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 |