[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / variables.c
blob2c8c1368e173a6bb326ba8cb38ebc99d4d93cea4
1 // Test this without pch.
2 // RUN: %clang_cc1 -include %s -fsyntax-only -verify %s
4 // Test with pch.
5 // RUN: %clang_cc1 -emit-pch -o %t %s
6 // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
8 #ifndef HEADER
9 #define HEADER
11 extern float y;
12 extern int *ip, x;
14 float z;
16 int z2 = 17;
18 #define MAKE_HAPPY(X) X##Happy
19 int MAKE_HAPPY(Very);
21 #define A_MACRO_IN_THE_PCH 492
22 #define FUNCLIKE_MACRO(X, Y) X ## Y
24 #define PASTE2(x,y) x##y
25 #define PASTE1(x,y) PASTE2(x,y)
26 #define UNIQUE(x) PASTE1(x,__COUNTER__)
28 int UNIQUE(a); // a0
29 int UNIQUE(a); // a1
31 #else
33 int *ip2 = &x;
34 float *fp = &ip; // expected-warning{{incompatible pointer types}}
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}}
39 int Q = A_MACRO_IN_THE_PCH;
41 int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH);
44 int UNIQUE(a); // a2
45 int *Arr[] = { &a0, &a1, &a2 };
47 #endif