blob: 25591dc5b1f2f058ccc2abfc57feee7395f9b68d [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -verify -fsyntax-only %s
Daniel Dunbar5466c7b2009-04-14 02:25:56 +00002
3static int g0; // expected-note{{previous definition}}
4int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
5
6static int g1;
7extern int g1;
8
9static int g2;
10__private_extern__ int g2;
11
12int g3; // expected-note{{previous definition}}
13static int g3; // expected-error{{static declaration of 'g3' follows non-static declaration}}
14
15extern int g4; // expected-note{{previous definition}}
16static int g4; // expected-error{{static declaration of 'g4' follows non-static declaration}}
17
18__private_extern__ int g5; // expected-note{{previous definition}}
19static int g5; // expected-error{{static declaration of 'g5' follows non-static declaration}}
20
21void f0() {
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000022 int g6; // expected-note {{previous}}
23 extern int g6; // expected-error {{extern declaration of 'g6' follows non-extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000024}
25
26void f1() {
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000027 int g7; // expected-note {{previous}}
28 __private_extern__ int g7; // expected-error {{extern declaration of 'g7' follows non-extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000029}
30
31void f2() {
32 extern int g8; // expected-note{{previous definition}}
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000033 int g8; // expected-error {{non-extern declaration of 'g8' follows extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000034}
35
36void f3() {
37 __private_extern__ int g9; // expected-note{{previous definition}}
Argyrios Kyrtzidis6684d852011-01-31 07:04:46 +000038 int g9; // expected-error {{non-extern declaration of 'g9' follows extern declaration}}
Daniel Dunbar5466c7b2009-04-14 02:25:56 +000039}
40
41void f4() {
42 extern int g10;
43 extern int g10;
44}
45
46void f5() {
47 __private_extern__ int g11;
48 __private_extern__ int g11;
49}
50
51void f6() {
52 // FIXME: Diagnose
53 extern int g12;
54 __private_extern__ int g12;
55}
56
57void f7() {
58 // FIXME: Diagnose
59 __private_extern__ int g13;
60 extern int g13;
61}
62
63struct s0;
64void f8() {
65 extern struct s0 g14;
66 __private_extern__ struct s0 g14;
67}
68struct s0 { int x; };
69
70void f9() {
71 extern int g15 = 0; // expected-error{{'extern' variable cannot have an initializer}}
72 // FIXME: linkage specifier in warning.
73 __private_extern__ int g16 = 0; // expected-error{{'extern' variable cannot have an initializer}}
74}
75
76extern int g17;
77int g17 = 0;
78
79extern int g18 = 0; // expected-warning{{'extern' variable has an initializer}}
80
81__private_extern__ int g19;
82int g19 = 0;
83
Steve Naroffee3899e2009-04-15 15:20:03 +000084__private_extern__ int g20 = 0;