1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li int outer1; // expected-note{{previous definition is here}} 4*67e74705SXin Li extern int outer2; // expected-note{{previous declaration is here}} 5*67e74705SXin Li int outer4; 6*67e74705SXin Li int outer4; // expected-note{{previous definition is here}} 7*67e74705SXin Li int outer5; 8*67e74705SXin Li int outer6(float); // expected-note{{previous definition is here}} 9*67e74705SXin Li int outer7(float); 10*67e74705SXin Li outer_test()11*67e74705SXin Livoid outer_test() { 12*67e74705SXin Li extern float outer1; // expected-error{{redeclaration of 'outer1' with a different type}} 13*67e74705SXin Li extern float outer2; // expected-error{{redeclaration of 'outer2' with a different type}} 14*67e74705SXin Li extern float outer3; // expected-note{{previous declaration is here}} 15*67e74705SXin Li double outer4; 16*67e74705SXin Li extern int outer5; // expected-note{{previous declaration is here}} 17*67e74705SXin Li extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}} 18*67e74705SXin Li int outer7; 19*67e74705SXin Li extern int outer8; // expected-note{{previous definition is here}} 20*67e74705SXin Li extern int outer9; 21*67e74705SXin Li { 22*67e74705SXin Li extern int outer9; // expected-note{{previous declaration is here}} 23*67e74705SXin Li } 24*67e74705SXin Li } 25*67e74705SXin Li 26*67e74705SXin Li int outer3; // expected-error{{redefinition of 'outer3' with a different type}} 27*67e74705SXin Li float outer4; // expected-error{{redefinition of 'outer4' with a different type}} 28*67e74705SXin Li float outer5; // expected-error{{redefinition of 'outer5' with a different type}} 29*67e74705SXin Li int outer8(int); // expected-error{{redefinition of 'outer8' as different kind of symbol}} 30*67e74705SXin Li float outer9; // expected-error{{redefinition of 'outer9' with a different type}} 31*67e74705SXin Li 32*67e74705SXin Li extern int outer13; // expected-note{{previous declaration is here}} outer_shadowing_test()33*67e74705SXin Livoid outer_shadowing_test() { 34*67e74705SXin Li extern int outer10; 35*67e74705SXin Li extern int outer11; // expected-note{{previous declaration is here}} 36*67e74705SXin Li extern int outer12; // expected-note{{previous declaration is here}} 37*67e74705SXin Li { 38*67e74705SXin Li float outer10; 39*67e74705SXin Li float outer11; 40*67e74705SXin Li float outer12; 41*67e74705SXin Li { 42*67e74705SXin Li extern int outer10; // okay 43*67e74705SXin Li extern float outer11; // expected-error{{redeclaration of 'outer11' with a different type}} 44*67e74705SXin Li static double outer12; 45*67e74705SXin Li { 46*67e74705SXin Li extern float outer12; // expected-error{{redeclaration of 'outer12' with a different type}} 47*67e74705SXin Li extern float outer13; // expected-error{{redeclaration of 'outer13' with a different type}} 48*67e74705SXin Li } 49*67e74705SXin Li } 50*67e74705SXin Li } 51*67e74705SXin Li } 52*67e74705SXin Li g18(void)53*67e74705SXin Livoid g18(void) { // expected-note{{'g18' declared here}} 54*67e74705SXin Li extern int g19; 55*67e74705SXin Li } 56*67e74705SXin Li int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \ 57*67e74705SXin Li // expected-warning{{incompatible pointer types}} 58*67e74705SXin Li 59*67e74705SXin Li // PR3645 60*67e74705SXin Li static int a; 61*67e74705SXin Li extern int a; // expected-note {{previous declaration is here}} 62*67e74705SXin Li int a; // expected-error {{non-static declaration of 'a' follows static declaration}} 63*67e74705SXin Li f(int x)64*67e74705SXin Livoid f(int x) { // expected-note {{previous definition is here}} 65*67e74705SXin Li extern int x; // expected-error {{extern declaration of 'x' follows non-extern declaration}} 66*67e74705SXin Li } 67*67e74705SXin Li 68*67e74705SXin Li extern int b[]; g20()69*67e74705SXin Livoid g20() { extern int b[3]; } // expected-note{{previous declaration is here}} g21()70*67e74705SXin Livoid g21() { extern int b[4]; } // expected-error{{redeclaration of 'b' with a different type: 'int [4]' vs 'int [3]'}} 71