xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/variables.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // Test this without pch.
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -include %s -fsyntax-only -verify %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // Test with pch.
5*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-pch -o %t %s
6*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc #ifndef HEADER
9*f4a2713aSLionel Sambuc #define HEADER
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc extern float y;
12*f4a2713aSLionel Sambuc extern int *ip, x;
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc float z;
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc int z2 = 17;
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc #define MAKE_HAPPY(X) X##Happy
19*f4a2713aSLionel Sambuc int MAKE_HAPPY(Very);
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc #define A_MACRO_IN_THE_PCH 492
22*f4a2713aSLionel Sambuc #define FUNCLIKE_MACRO(X, Y) X ## Y
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc #define PASTE2(x,y) x##y
25*f4a2713aSLionel Sambuc #define PASTE1(x,y) PASTE2(x,y)
26*f4a2713aSLionel Sambuc #define UNIQUE(x) PASTE1(x,__COUNTER__)
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc int UNIQUE(a);  // a0
29*f4a2713aSLionel Sambuc int UNIQUE(a);  // a1
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc #else
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc int *ip2 = &x;
34*f4a2713aSLionel Sambuc float *fp = &ip; // expected-warning{{incompatible pointer types}}
35*f4a2713aSLionel Sambuc double z; // expected-error{{redefinition}} expected-note@14{{previous}}
36*f4a2713aSLionel Sambuc int z2 = 18; // expected-error{{redefinition}} expected-note@16{{previous}}
37*f4a2713aSLionel Sambuc double VeryHappy; // expected-error{{redefinition}} expected-note@19{{previous definition is here}}
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc int Q = A_MACRO_IN_THE_PCH;
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH);
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc int UNIQUE(a);  // a2
45*f4a2713aSLionel Sambuc int *Arr[] = { &a0, &a1, &a2 };
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc #endif
48