1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc struct S 4*f4a2713aSLionel Sambuc { 5*f4a2713aSLionel Sambuc static int v1; // expected-note{{previous declaration is here}} 6*f4a2713aSLionel Sambuc int v1; //expected-error{{duplicate member 'v1'}} 7*f4a2713aSLionel Sambuc int v; //expected-note 2{{previous definition is here}} \ 8*f4a2713aSLionel Sambuc // expected-note{{previous declaration is here}} 9*f4a2713aSLionel Sambuc static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} 10*f4a2713aSLionel Sambuc int v; //expected-error{{duplicate member 'v'}} 11*f4a2713aSLionel Sambuc static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} 12*f4a2713aSLionel Sambuc enum EnumT { E = 10 }; 13*f4a2713aSLionel Sambuc friend struct M; 14*f4a2713aSLionel Sambuc struct X; //expected-note{{forward declaration of 'S::X'}} 15*f4a2713aSLionel Sambuc friend struct X; 16*f4a2713aSLionel Sambuc }; 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc S::EnumT Evar = S::E; // ok 19*f4a2713aSLionel Sambuc S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}} 20*f4a2713aSLionel Sambuc S::M m; //expected-error{{no type named 'M' in 'S'}} 21*f4a2713aSLionel Sambuc S::X x; //expected-error{{variable has incomplete type 'S::X'}} 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc struct S2 25*f4a2713aSLionel Sambuc { 26*f4a2713aSLionel Sambuc static int v2; // expected-note{{previous declaration is here}} 27*f4a2713aSLionel Sambuc static int v2; //expected-error{{duplicate member 'v2'}} 28*f4a2713aSLionel Sambuc }; 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc struct S3 31*f4a2713aSLionel Sambuc { 32*f4a2713aSLionel Sambuc static int v3; 33*f4a2713aSLionel Sambuc struct S4 34*f4a2713aSLionel Sambuc { 35*f4a2713aSLionel Sambuc static int v3; 36*f4a2713aSLionel Sambuc }; 37*f4a2713aSLionel Sambuc }; 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc struct S4 40*f4a2713aSLionel Sambuc { 41*f4a2713aSLionel Sambuc static int v4; 42*f4a2713aSLionel Sambuc }; 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc int S4::v4; //expected-note{{previous definition is here}} 45*f4a2713aSLionel Sambuc int S4::v4; //expected-error{{redefinition of 'v4'}} 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc struct S5 48*f4a2713aSLionel Sambuc { 49*f4a2713aSLionel Sambuc static int v5; //expected-note{{previous definition is here}} v5S550*f4a2713aSLionel Sambuc void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}} 51*f4a2713aSLionel Sambuc v6S552*f4a2713aSLionel Sambuc void v6() { } //expected-note{{previous definition is here}} 53*f4a2713aSLionel Sambuc static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}} 54*f4a2713aSLionel Sambuc v7S555*f4a2713aSLionel Sambuc void v7() { } v7S556*f4a2713aSLionel Sambuc void v7(int) { } //expected-note{{previous definition is here}} 57*f4a2713aSLionel Sambuc static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}} 58*f4a2713aSLionel Sambuc 59*f4a2713aSLionel Sambuc void v8(); 60*f4a2713aSLionel Sambuc int v8(int); //expected-note{{previous declaration is here}} 61*f4a2713aSLionel Sambuc int v8; //expected-error{{duplicate member 'v8'}} 62*f4a2713aSLionel Sambuc 63*f4a2713aSLionel Sambuc 64*f4a2713aSLionel Sambuc }; 65*f4a2713aSLionel Sambuc 66*f4a2713aSLionel Sambuc namespace PR8245 { 67*f4a2713aSLionel Sambuc class X { 68*f4a2713aSLionel Sambuc public: 69*f4a2713aSLionel Sambuc template<class C> 70*f4a2713aSLionel Sambuc class Inner { 71*f4a2713aSLionel Sambuc public: 72*f4a2713aSLionel Sambuc void foo(bool bar = true); 73*f4a2713aSLionel Sambuc int bam; 74*f4a2713aSLionel Sambuc }; 75*f4a2713aSLionel Sambuc 76*f4a2713aSLionel Sambuc Inner<int> _foo; 77*f4a2713aSLionel Sambuc }; 78*f4a2713aSLionel Sambuc f()79*f4a2713aSLionel Sambuc void f() { 80*f4a2713aSLionel Sambuc X::Inner<int> c2i; 81*f4a2713aSLionel Sambuc X::Inner<float> c2f; 82*f4a2713aSLionel Sambuc c2i.foo(); 83*f4a2713aSLionel Sambuc c2f.foo(); 84*f4a2713aSLionel Sambuc } 85*f4a2713aSLionel Sambuc 86*f4a2713aSLionel Sambuc class Y { 87*f4a2713aSLionel Sambuc class Inner { 88*f4a2713aSLionel Sambuc void foo(int = sizeof(Y)); 89*f4a2713aSLionel Sambuc }; 90*f4a2713aSLionel Sambuc }; 91*f4a2713aSLionel Sambuc } 92