xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/private-extern.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern -fmodules %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc static int g0; // expected-note{{previous definition}}
5*f4a2713aSLionel Sambuc int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc static int g1;
8*f4a2713aSLionel Sambuc extern int g1;
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc static int g2;
11*f4a2713aSLionel Sambuc __private_extern__ int g2;
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc int g3; // expected-note{{previous definition}}
14*f4a2713aSLionel Sambuc static int g3; // expected-error{{static declaration of 'g3' follows non-static declaration}}
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc extern int g4; // expected-note{{previous definition}}
17*f4a2713aSLionel Sambuc static int g4; // expected-error{{static declaration of 'g4' follows non-static declaration}}
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc __private_extern__ int g5; // expected-note{{previous definition}}
20*f4a2713aSLionel Sambuc static int g5; // expected-error{{static declaration of 'g5' follows non-static declaration}}
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc void f0() {
23*f4a2713aSLionel Sambuc   int g6; // expected-note {{previous}}
24*f4a2713aSLionel Sambuc   extern int g6; // expected-error {{extern declaration of 'g6' follows non-extern declaration}}
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc void f1() {
28*f4a2713aSLionel Sambuc   int g7; // expected-note {{previous}}
29*f4a2713aSLionel Sambuc   __private_extern__ int g7; // expected-error {{extern declaration of 'g7' follows non-extern declaration}}
30*f4a2713aSLionel Sambuc }
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc void f2() {
33*f4a2713aSLionel Sambuc   extern int g8; // expected-note{{previous definition}}
34*f4a2713aSLionel Sambuc   int g8; // expected-error {{non-extern declaration of 'g8' follows extern declaration}}
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc void f3() {
38*f4a2713aSLionel Sambuc   __private_extern__ int g9; // expected-note{{previous definition}}
39*f4a2713aSLionel Sambuc   int g9; // expected-error {{non-extern declaration of 'g9' follows extern declaration}}
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc void f4() {
43*f4a2713aSLionel Sambuc   extern int g10;
44*f4a2713aSLionel Sambuc   extern int g10;
45*f4a2713aSLionel Sambuc }
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc void f5() {
48*f4a2713aSLionel Sambuc   __private_extern__ int g11;
49*f4a2713aSLionel Sambuc   __private_extern__ int g11;
50*f4a2713aSLionel Sambuc }
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc void f6() {
53*f4a2713aSLionel Sambuc   // FIXME: Diagnose
54*f4a2713aSLionel Sambuc   extern int g12;
55*f4a2713aSLionel Sambuc   __private_extern__ int g12;
56*f4a2713aSLionel Sambuc }
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc void f7() {
59*f4a2713aSLionel Sambuc   // FIXME: Diagnose
60*f4a2713aSLionel Sambuc   __private_extern__ int g13;
61*f4a2713aSLionel Sambuc   extern int g13;
62*f4a2713aSLionel Sambuc }
63*f4a2713aSLionel Sambuc 
64*f4a2713aSLionel Sambuc struct s0;
65*f4a2713aSLionel Sambuc void f8() {
66*f4a2713aSLionel Sambuc   extern struct s0 g14;
67*f4a2713aSLionel Sambuc   __private_extern__ struct s0 g14;
68*f4a2713aSLionel Sambuc }
69*f4a2713aSLionel Sambuc struct s0 { int x; };
70*f4a2713aSLionel Sambuc 
71*f4a2713aSLionel Sambuc void f9() {
72*f4a2713aSLionel Sambuc   extern int g15 = 0; // expected-error{{'extern' variable cannot have an initializer}}
73*f4a2713aSLionel Sambuc   // FIXME: linkage specifier in warning.
74*f4a2713aSLionel Sambuc   __private_extern__ int g16 = 0; // expected-error{{'extern' variable cannot have an initializer}}
75*f4a2713aSLionel Sambuc }
76*f4a2713aSLionel Sambuc 
77*f4a2713aSLionel Sambuc extern int g17;
78*f4a2713aSLionel Sambuc int g17 = 0;
79*f4a2713aSLionel Sambuc 
80*f4a2713aSLionel Sambuc extern int g18 = 0; // expected-warning{{'extern' variable has an initializer}}
81*f4a2713aSLionel Sambuc 
82*f4a2713aSLionel Sambuc __private_extern__ int g19;
83*f4a2713aSLionel Sambuc int g19 = 0;
84*f4a2713aSLionel Sambuc 
85*f4a2713aSLionel Sambuc __private_extern__ int g20 = 0;
86