blob: 23297f3a220621cf90f4a72bd2239cfeedb1331d [file] [log] [blame]
Douglas Gregorcda9c672009-02-16 17:45:42 +00001// RUN: clang %s -fsyntax-only -verify
Steve Naroffb7b032e2008-01-30 00:44:01 +00002
Douglas Gregora03aca82009-03-10 21:58:27 +00003// PR3310
4struct a x1; // expected-note 2{{forward declaration of 'struct a'}}
5static struct a x2; // expected-error{{variable has incomplete type 'struct a'}}
6struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}}
7struct a {int x;};
Douglas Gregor275a3692009-03-10 23:43:53 +00008static struct a x2_okay;
9struct a x3_okay[10];
10struct b x4; // expected-error{{tentative definition has type 'struct b' that is never completed}} \
11 // expected-note{{forward declaration of 'struct b'}}
Douglas Gregora03aca82009-03-10 21:58:27 +000012
Steve Naroffb7b032e2008-01-30 00:44:01 +000013const int a [1] = {1};
14extern const int a[];
15
16extern const int b[];
17const int b [1] = {1};
18
19extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}
20const int c[];
21
Chris Lattner5f4a6822008-11-23 23:12:31 +000022int i1 = 1; // expected-note {{previous definition is here}}
Douglas Gregorcda9c672009-02-16 17:45:42 +000023int i1 = 2; // expected-error {{redefinition of 'i1'}}
Steve Naroffff9eb1f2008-08-08 17:50:35 +000024int i1;
Steve Naroffb7b032e2008-01-30 00:44:01 +000025int i1;
Chris Lattner5f4a6822008-11-23 23:12:31 +000026extern int i1; // expected-note {{previous definition is here}}
Douglas Gregorcda9c672009-02-16 17:45:42 +000027static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
28
Douglas Gregor275a3692009-03-10 23:43:53 +000029static int i2 = 5; // expected-note 1 {{previous definition is here}}
30int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}
Steve Naroffb7b032e2008-01-30 00:44:01 +000031
Steve Naroff235549c2008-05-12 22:36:43 +000032__private_extern__ int pExtern;
33int pExtern = 0;
34
Steve Naroffff9eb1f2008-08-08 17:50:35 +000035int i4;
36int i4;
37extern int i4;
38
Steve Naroff907747b2008-08-09 16:04:40 +000039int (*pToArray)[];
40int (*pToArray)[8];
41
Steve Narofff855e6f2008-08-10 15:20:13 +000042int redef[10];
Chris Lattner5f4a6822008-11-23 23:12:31 +000043int redef[]; // expected-note {{previous definition is here}}
Steve Narofff855e6f2008-08-10 15:20:13 +000044int redef[11]; // expected-error{{redefinition of 'redef'}}
45
Steve Naroffb7b032e2008-01-30 00:44:01 +000046void func() {
Chris Lattner5f4a6822008-11-23 23:12:31 +000047 extern int i1; // expected-note {{previous definition is here}}
Steve Naroffb7b032e2008-01-30 00:44:01 +000048 static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
49}
Steve Naroff094cefb2008-09-17 14:05:40 +000050
51void func2(void)
52{
53 extern double *p;
54 extern double *p;
55}
Douglas Gregora03aca82009-03-10 21:58:27 +000056