blob: 3c1ab0e65874a921d27aef65c1350e475a40bc0d [file] [log] [blame]
Douglas Gregor75a45ba2009-02-16 17:45:42 +00001// RUN: clang %s -fsyntax-only -verify
Steve Naroff1e787362008-01-30 00:44:01 +00002
Douglas Gregor81457422009-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;};
8struct b x4; // FIXME: error because 'struct b' is never defined
9
Steve Naroff1e787362008-01-30 00:44:01 +000010const int a [1] = {1};
11extern const int a[];
12
13extern const int b[];
14const int b [1] = {1};
15
16extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}
17const int c[];
18
Chris Lattner0369c572008-11-23 23:12:31 +000019int i1 = 1; // expected-note {{previous definition is here}}
Douglas Gregor75a45ba2009-02-16 17:45:42 +000020int i1 = 2; // expected-error {{redefinition of 'i1'}}
Steve Naroff5bb8f222008-08-08 17:50:35 +000021int i1;
Steve Naroff1e787362008-01-30 00:44:01 +000022int i1;
Chris Lattner0369c572008-11-23 23:12:31 +000023extern int i1; // expected-note {{previous definition is here}}
Douglas Gregor75a45ba2009-02-16 17:45:42 +000024static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
25
26static int i2 = 5; // expected-note 2 {{previous definition is here}}
27int i2 = 3; // expected-error{{redefinition of 'i2'}} expected-error{{non-static declaration of 'i2' follows static declaration}}
Steve Naroff1e787362008-01-30 00:44:01 +000028
Steve Naroffa98fe192008-05-12 22:36:43 +000029__private_extern__ int pExtern;
30int pExtern = 0;
31
Steve Naroff5bb8f222008-08-08 17:50:35 +000032int i4;
33int i4;
34extern int i4;
35
Steve Naroff239255d2008-08-09 16:04:40 +000036int (*pToArray)[];
37int (*pToArray)[8];
38
Steve Naroff84e37352008-08-10 15:20:13 +000039int redef[10];
Chris Lattner0369c572008-11-23 23:12:31 +000040int redef[]; // expected-note {{previous definition is here}}
Steve Naroff84e37352008-08-10 15:20:13 +000041int redef[11]; // expected-error{{redefinition of 'redef'}}
42
Steve Naroff1e787362008-01-30 00:44:01 +000043void func() {
Chris Lattner0369c572008-11-23 23:12:31 +000044 extern int i1; // expected-note {{previous definition is here}}
Steve Naroff1e787362008-01-30 00:44:01 +000045 static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
46}
Steve Naroffa5629372008-09-17 14:05:40 +000047
48void func2(void)
49{
50 extern double *p;
51 extern double *p;
52}
Douglas Gregor81457422009-03-10 21:58:27 +000053