blob: b15537bfa0cdcd9cae817535ff26d613ed22f7ef [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %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'}}
Douglas Gregorec8b59f2009-07-20 18:46:59 +00005static struct a x2; // expected-warning{{tentative definition of variable with internal linkage has incomplete non-array type 'struct a'}}
Douglas Gregora03aca82009-03-10 21:58:27 +00006struct 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 Lattnereaaebc72009-04-25 08:06:05 +000026extern int i5; // expected-note {{previous definition is here}}
27static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}}
Douglas Gregorcda9c672009-02-16 17:45:42 +000028
Douglas Gregor275a3692009-03-10 23:43:53 +000029static int i2 = 5; // expected-note 1 {{previous definition is here}}
Douglas Gregor38179b22009-03-23 16:17:01 +000030int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}
31
32static int i3 = 5;
33extern int i3;
Steve Naroffb7b032e2008-01-30 00:44:01 +000034
Steve Naroff235549c2008-05-12 22:36:43 +000035__private_extern__ int pExtern;
36int pExtern = 0;
37
Steve Naroffff9eb1f2008-08-08 17:50:35 +000038int i4;
39int i4;
40extern int i4;
41
Steve Naroff907747b2008-08-09 16:04:40 +000042int (*pToArray)[];
43int (*pToArray)[8];
44
Steve Narofff855e6f2008-08-10 15:20:13 +000045int redef[10];
Chris Lattner5f4a6822008-11-23 23:12:31 +000046int redef[]; // expected-note {{previous definition is here}}
Steve Narofff855e6f2008-08-10 15:20:13 +000047int redef[11]; // expected-error{{redefinition of 'redef'}}
48
Steve Naroffb7b032e2008-01-30 00:44:01 +000049void func() {
Chris Lattnereaaebc72009-04-25 08:06:05 +000050 extern int i6; // expected-note {{previous definition is here}}
51 static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
Steve Naroffb7b032e2008-01-30 00:44:01 +000052}
Steve Naroff094cefb2008-09-17 14:05:40 +000053
54void func2(void)
55{
56 extern double *p;
57 extern double *p;
58}
Douglas Gregora03aca82009-03-10 21:58:27 +000059
Douglas Gregorb6c8c8b2009-04-21 17:11:58 +000060// <rdar://problem/6808352>
61static int a0[];
62static int b0;
63
64static int a0[] = { 4 };
65static int b0 = 5;