blob: 0c13c92bba7749fab38653b6f04d559705e85efd [file] [log] [blame]
Fariborz Jahanian767a1a22012-08-17 21:44:55 +00001// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
Richard Smithd613ac92013-04-04 01:51:11 +00002// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern -fmodules %s
Daniel Dunbar5466c7b2009-04-14 02:25:56 +00003
4static int g0; // expected-note{{previous definition}}
5int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
6
7static int g1;
8extern int g1;
9
10static int g2;
11__private_extern__ int g2;
12
13int g3; // expected-note{{previous definition}}
14static int g3; // expected-error{{static declaration of 'g3' follows non-static declaration}}
15
Stephen Hinesc568f1e2014-07-21 00:47:37 -070016extern int g4; // expected-note{{previous declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000017static int g4; // expected-error{{static declaration of 'g4' follows non-static declaration}}
18
Stephen Hinesc568f1e2014-07-21 00:47:37 -070019__private_extern__ int g5; // expected-note{{previous declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000020static int g5; // expected-error{{static declaration of 'g5' follows non-static declaration}}
21
22void f0() {
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000023 int g6; // expected-note {{previous}}
24 extern int g6; // expected-error {{extern declaration of 'g6' follows non-extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000025}
26
27void f1() {
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000028 int g7; // expected-note {{previous}}
29 __private_extern__ int g7; // expected-error {{extern declaration of 'g7' follows non-extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000030}
31
32void f2() {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070033 extern int g8; // expected-note{{previous declaration}}
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000034 int g8; // expected-error {{non-extern declaration of 'g8' follows extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000035}
36
37void f3() {
Stephen Hinesc568f1e2014-07-21 00:47:37 -070038 __private_extern__ int g9; // expected-note{{previous declaration}}
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000039 int g9; // expected-error {{non-extern declaration of 'g9' follows extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000040}
41
42void f4() {
43 extern int g10;
44 extern int g10;
45}
46
47void f5() {
48 __private_extern__ int g11;
49 __private_extern__ int g11;
50}
51
52void f6() {
53 // FIXME: Diagnose
54 extern int g12;
55 __private_extern__ int g12;
56}
57
58void f7() {
59 // FIXME: Diagnose
60 __private_extern__ int g13;
61 extern int g13;
62}
63
64struct s0;
65void f8() {
66 extern struct s0 g14;
67 __private_extern__ struct s0 g14;
68}
69struct s0 { int x; };
70
71void f9() {
72 extern int g15 = 0; // expected-error{{'extern' variable cannot have an initializer}}
73 // FIXME: linkage specifier in warning.
74 __private_extern__ int g16 = 0; // expected-error{{'extern' variable cannot have an initializer}}
75}
76
77extern int g17;
78int g17 = 0;
79
80extern int g18 = 0; // expected-warning{{'extern' variable has an initializer}}
81
82__private_extern__ int g19;
83int g19 = 0;
84
Steve Naroffee3899e2009-04-15 15:20:03 +000085__private_extern__ int g20 = 0;