private-extern.c revision a5728872c7702ddd09537c95bc3cbd20e1f2fb09
1// RUN: %clang_cc1 -verify -fsyntax-only %s 2 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() { 22 // FIXME: Diagnose this? 23 int g6; 24 extern int g6; 25} 26 27void f1() { 28 // FIXME: Diagnose this? 29 int g7; 30 __private_extern__ int g7; 31} 32 33void f2() { 34 extern int g8; // expected-note{{previous definition}} 35 // FIXME: Improve this diagnostic. 36 int g8; // expected-error{{redefinition of 'g8'}} 37} 38 39void f3() { 40 __private_extern__ int g9; // expected-note{{previous definition}} 41 // FIXME: Improve this diagnostic. 42 int g9; // expected-error{{redefinition of 'g9'}} 43} 44 45void f4() { 46 extern int g10; 47 extern int g10; 48} 49 50void f5() { 51 __private_extern__ int g11; 52 __private_extern__ int g11; 53} 54 55void f6() { 56 // FIXME: Diagnose 57 extern int g12; 58 __private_extern__ int g12; 59} 60 61void f7() { 62 // FIXME: Diagnose 63 __private_extern__ int g13; 64 extern int g13; 65} 66 67struct s0; 68void f8() { 69 extern struct s0 g14; 70 __private_extern__ struct s0 g14; 71} 72struct s0 { int x; }; 73 74void f9() { 75 extern int g15 = 0; // expected-error{{'extern' variable cannot have an initializer}} 76 // FIXME: linkage specifier in warning. 77 __private_extern__ int g16 = 0; // expected-error{{'extern' variable cannot have an initializer}} 78} 79 80extern int g17; 81int g17 = 0; 82 83extern int g18 = 0; // expected-warning{{'extern' variable has an initializer}} 84 85__private_extern__ int g19; 86int g19 = 0; 87 88__private_extern__ int g20 = 0; 89