blob: 2c8c1368e173a6bb326ba8cb38ebc99d4d93cea4 [file] [log] [blame]
Chris Lattner285d03f2009-04-11 20:52:19 +00001// Test this without pch.
Argyrios Kyrtzidisb73377e2011-07-07 03:40:34 +00002// RUN: %clang_cc1 -include %s -fsyntax-only -verify %s
Chris Lattner285d03f2009-04-11 20:52:19 +00003
4// Test with pch.
Argyrios Kyrtzidisb73377e2011-07-07 03:40:34 +00005// RUN: %clang_cc1 -emit-pch -o %t %s
Daniel Dunbara5728872009-12-15 20:14:24 +00006// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
Douglas Gregor2cf26342009-04-09 22:27:44 +00007
Argyrios Kyrtzidisb73377e2011-07-07 03:40:34 +00008#ifndef HEADER
9#define HEADER
10
11extern float y;
12extern int *ip, x;
13
Jordan Rose78541c42012-07-11 19:58:23 +000014float z;
Argyrios Kyrtzidisb73377e2011-07-07 03:40:34 +000015
Jordan Rose78541c42012-07-11 19:58:23 +000016int z2 = 17;
Argyrios Kyrtzidisb73377e2011-07-07 03:40:34 +000017
18#define MAKE_HAPPY(X) X##Happy
Jordan Rose78541c42012-07-11 19:58:23 +000019int MAKE_HAPPY(Very);
Argyrios Kyrtzidisb73377e2011-07-07 03:40:34 +000020
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
28int UNIQUE(a); // a0
29int UNIQUE(a); // a1
30
31#else
32
Douglas Gregor2cf26342009-04-09 22:27:44 +000033int *ip2 = &x;
34float *fp = &ip; // expected-warning{{incompatible pointer types}}
Jordan Rose78541c42012-07-11 19:58:23 +000035double z; // expected-error{{redefinition}} expected-note@14{{previous}}
36int z2 = 18; // expected-error{{redefinition}} expected-note@16{{previous}}
37double VeryHappy; // expected-error{{redefinition}} expected-note@19{{previous definition is here}}
Chris Lattner531cc832009-04-10 22:13:17 +000038
39int Q = A_MACRO_IN_THE_PCH;
40
Chris Lattnerc1f9d822009-04-13 01:29:17 +000041int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH);
42
43
44int UNIQUE(a); // a2
45int *Arr[] = { &a0, &a1, &a2 };
Argyrios Kyrtzidisb73377e2011-07-07 03:40:34 +000046
47#endif