blob: bf2b1e4ee6a5bb211c39ccd77093dac7b003650d [file] [log] [blame]
Fariborz Jahanian4cc83c22012-08-15 18:42:26 +00001// RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -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
Fariborz Jahanian4cc83c22012-08-15 18:42:26 +000035// rdar://7703982
Fariborz Jahanian767a1a22012-08-17 21:44:55 +000036__private_extern__ int pExtern; // expected-warning {{use of __private_extern__ on a declaration may not produce external symbol private to the linkage unit and is deprecated}} \
37// expected-note {{use __attribute__((visibility("hidden"))) attribute instead}}
Steve Naroff235549c2008-05-12 22:36:43 +000038int pExtern = 0;
39
Steve Naroffff9eb1f2008-08-08 17:50:35 +000040int i4;
41int i4;
42extern int i4;
43
Steve Naroff907747b2008-08-09 16:04:40 +000044int (*pToArray)[];
45int (*pToArray)[8];
46
Steve Narofff855e6f2008-08-10 15:20:13 +000047int redef[10];
Chris Lattner5f4a6822008-11-23 23:12:31 +000048int redef[]; // expected-note {{previous definition is here}}
Steve Narofff855e6f2008-08-10 15:20:13 +000049int redef[11]; // expected-error{{redefinition of 'redef'}}
50
Steve Naroffb7b032e2008-01-30 00:44:01 +000051void func() {
Chris Lattnereaaebc72009-04-25 08:06:05 +000052 extern int i6; // expected-note {{previous definition is here}}
53 static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
Steve Naroffb7b032e2008-01-30 00:44:01 +000054}
Steve Naroff094cefb2008-09-17 14:05:40 +000055
56void func2(void)
57{
58 extern double *p;
59 extern double *p;
60}
Douglas Gregora03aca82009-03-10 21:58:27 +000061
Douglas Gregorb6c8c8b2009-04-21 17:11:58 +000062// <rdar://problem/6808352>
63static int a0[];
64static int b0;
65
66static int a0[] = { 4 };
67static int b0 = 5;