xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/tentative-decls.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -verify
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // PR3310
4f4a2713aSLionel Sambuc struct a x1; // expected-note 2{{forward declaration of 'struct a'}}
5f4a2713aSLionel Sambuc static struct a x2; // expected-warning{{tentative definition of variable with internal linkage has incomplete non-array type 'struct a'}}
6f4a2713aSLionel Sambuc struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}}
7f4a2713aSLionel Sambuc struct a {int x;};
8f4a2713aSLionel Sambuc static struct a x2_okay;
9f4a2713aSLionel Sambuc struct a x3_okay[10];
10f4a2713aSLionel Sambuc struct b x4; // expected-error{{tentative definition has type 'struct b' that is never completed}} \
11f4a2713aSLionel Sambuc             // expected-note{{forward declaration of 'struct b'}}
12f4a2713aSLionel Sambuc 
13f4a2713aSLionel Sambuc const int a [1] = {1};
14f4a2713aSLionel Sambuc extern const int a[];
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc extern const int b[];
17f4a2713aSLionel Sambuc const int b [1] = {1};
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}
20f4a2713aSLionel Sambuc const int c[];
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc int i1 = 1; // expected-note {{previous definition is here}}
23f4a2713aSLionel Sambuc int i1 = 2; // expected-error {{redefinition of 'i1'}}
24f4a2713aSLionel Sambuc int i1;
25f4a2713aSLionel Sambuc int i1;
26*0a6a1f1dSLionel Sambuc extern int i5; // expected-note {{previous declaration is here}}
27f4a2713aSLionel Sambuc static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}}
28f4a2713aSLionel Sambuc 
29f4a2713aSLionel Sambuc static int i2 = 5; // expected-note 1 {{previous definition is here}}
30f4a2713aSLionel Sambuc int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}
31f4a2713aSLionel Sambuc 
32f4a2713aSLionel Sambuc static int i3 = 5;
33f4a2713aSLionel Sambuc extern int i3;
34f4a2713aSLionel Sambuc 
35f4a2713aSLionel Sambuc // rdar://7703982
36f4a2713aSLionel Sambuc __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}} \
37f4a2713aSLionel Sambuc // expected-note {{use __attribute__((visibility("hidden"))) attribute instead}}
38f4a2713aSLionel Sambuc int pExtern = 0;
39f4a2713aSLionel Sambuc 
40f4a2713aSLionel Sambuc int i4;
41f4a2713aSLionel Sambuc int i4;
42f4a2713aSLionel Sambuc extern int i4;
43f4a2713aSLionel Sambuc 
44f4a2713aSLionel Sambuc int (*pToArray)[];
45f4a2713aSLionel Sambuc int (*pToArray)[8];
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc int redef[10];
48f4a2713aSLionel Sambuc int redef[];  // expected-note {{previous definition is here}}
49f4a2713aSLionel Sambuc int redef[11]; // expected-error{{redefinition of 'redef'}}
50f4a2713aSLionel Sambuc 
func()51f4a2713aSLionel Sambuc void func() {
52*0a6a1f1dSLionel Sambuc   extern int i6; // expected-note {{previous declaration is here}}
53f4a2713aSLionel Sambuc   static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
54f4a2713aSLionel Sambuc }
55f4a2713aSLionel Sambuc 
func2(void)56f4a2713aSLionel Sambuc void func2(void)
57f4a2713aSLionel Sambuc {
58f4a2713aSLionel Sambuc   extern double *p;
59f4a2713aSLionel Sambuc   extern double *p;
60f4a2713aSLionel Sambuc }
61f4a2713aSLionel Sambuc 
62f4a2713aSLionel Sambuc // <rdar://problem/6808352>
63f4a2713aSLionel Sambuc static int a0[];
64f4a2713aSLionel Sambuc static int b0;
65f4a2713aSLionel Sambuc 
66f4a2713aSLionel Sambuc static int a0[] = { 4 };
67f4a2713aSLionel Sambuc static int b0 = 5;
68