blob: fc0d50086eaa72c87b01f076f8512c517504bf13 [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;};
Douglas Gregor0760fa12009-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 Gregor81457422009-03-10 21:58:27 +000012
Steve Naroff1e787362008-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 Lattner0369c572008-11-23 23:12:31 +000022int i1 = 1; // expected-note {{previous definition is here}}
Douglas Gregor75a45ba2009-02-16 17:45:42 +000023int i1 = 2; // expected-error {{redefinition of 'i1'}}
Steve Naroff5bb8f222008-08-08 17:50:35 +000024int i1;
Steve Naroff1e787362008-01-30 00:44:01 +000025int i1;
Chris Lattner0369c572008-11-23 23:12:31 +000026extern int i1; // expected-note {{previous definition is here}}
Douglas Gregor75a45ba2009-02-16 17:45:42 +000027static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
28
Douglas Gregor0760fa12009-03-10 23:43:53 +000029static int i2 = 5; // expected-note 1 {{previous definition is here}}
Douglas Gregor37311622009-03-19 22:01:50 +000030int i2 = 3; // expected-error{{redefinition of 'i2'}}
Steve Naroff1e787362008-01-30 00:44:01 +000031
Steve Naroffa98fe192008-05-12 22:36:43 +000032__private_extern__ int pExtern;
33int pExtern = 0;
34
Steve Naroff5bb8f222008-08-08 17:50:35 +000035int i4;
36int i4;
37extern int i4;
38
Steve Naroff239255d2008-08-09 16:04:40 +000039int (*pToArray)[];
40int (*pToArray)[8];
41
Steve Naroff84e37352008-08-10 15:20:13 +000042int redef[10];
Chris Lattner0369c572008-11-23 23:12:31 +000043int redef[]; // expected-note {{previous definition is here}}
Steve Naroff84e37352008-08-10 15:20:13 +000044int redef[11]; // expected-error{{redefinition of 'redef'}}
45
Steve Naroff1e787362008-01-30 00:44:01 +000046void func() {
Chris Lattner0369c572008-11-23 23:12:31 +000047 extern int i1; // expected-note {{previous definition is here}}
Steve Naroff1e787362008-01-30 00:44:01 +000048 static int i1; // expected-error{{static declaration of 'i1' follows non-static declaration}}
49}
Steve Naroffa5629372008-09-17 14:05:40 +000050
51void func2(void)
52{
53 extern double *p;
54 extern double *p;
55}
Douglas Gregor81457422009-03-10 21:58:27 +000056