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