blob: e14540ba841746a6ef85580fe72b78157435ec5a [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
36__private_extern__ int pExtern; // expected-warning {{Use of __private_extern__ on tentative definition has unexpected behaviour}}
Steve Naroff235549c2008-05-12 22:36:43 +000037int pExtern = 0;
38
Steve Naroffff9eb1f2008-08-08 17:50:35 +000039int i4;
40int i4;
41extern int i4;
42
Steve Naroff907747b2008-08-09 16:04:40 +000043int (*pToArray)[];
44int (*pToArray)[8];
45
Steve Narofff855e6f2008-08-10 15:20:13 +000046int redef[10];
Chris Lattner5f4a6822008-11-23 23:12:31 +000047int redef[]; // expected-note {{previous definition is here}}
Steve Narofff855e6f2008-08-10 15:20:13 +000048int redef[11]; // expected-error{{redefinition of 'redef'}}
49
Steve Naroffb7b032e2008-01-30 00:44:01 +000050void func() {
Chris Lattnereaaebc72009-04-25 08:06:05 +000051 extern int i6; // expected-note {{previous definition is here}}
52 static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
Steve Naroffb7b032e2008-01-30 00:44:01 +000053}
Steve Naroff094cefb2008-09-17 14:05:40 +000054
55void func2(void)
56{
57 extern double *p;
58 extern double *p;
59}
Douglas Gregora03aca82009-03-10 21:58:27 +000060
Douglas Gregorb6c8c8b2009-04-21 17:11:58 +000061// <rdar://problem/6808352>
62static int a0[];
63static int b0;
64
65static int a0[] = { 4 };
66static int b0 = 5;