// RUN: %clang_cc1 -verify %s -fcxx-exceptions -std=c++1y namespace N {} template struct X {}; // expected-error {{declaration of 'T' shadows template parameter}} template struct Y { // expected-note 18{{declared here}} template struct A {}; // expected-error {{declaration of 'T' shadows template parameter}} struct B { template struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} }; struct C { template void T(); // expected-error {{declaration of 'T' shadows template parameter}} }; struct D { struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} }; struct E { typedef int T; // expected-error {{declaration of 'T' shadows template parameter}} }; struct F { using T = int; // expected-error {{declaration of 'T' shadows template parameter}} }; struct G { int T; // expected-error {{declaration of 'T' shadows template parameter}} }; struct H { static int T; // expected-error {{declaration of 'T' shadows template parameter}} }; struct I { void T(); // expected-error {{declaration of 'T' shadows template parameter}} }; struct J { enum T { e }; // expected-error {{declaration of 'T' shadows template parameter}} }; struct K { enum E { T }; // expected-error {{declaration of 'T' shadows template parameter}} }; void a() { extern int T; // expected-error {{declaration of 'T' shadows template parameter}} } void b() { int T; // expected-error {{declaration of 'T' shadows template parameter}} } void c() { try {} catch (int T) {} // expected-error {{declaration of 'T' shadows template parameter}} } void d() { void T(); // expected-error {{declaration of 'T' shadows template parameter}} } void e() { namespace T = N; // expected-error {{declaration of 'T' shadows template parameter}} } // FIXME: These diagnostics are poorly worded. Lookup for the elaborated type // specifier finds the template parameter in this case, which is ill-formed // because it's not a struct. void f() { struct T *p; // expected-error {{declaration of 'T' shadows template parameter}} } friend struct T; // expected-error {{declaration of 'T' shadows template parameter}} }; template struct Z { // expected-note 16{{declared here}} template struct A {}; // expected-error {{declaration of 'T' shadows template parameter}} struct B { template struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} }; struct C { template void T(); // expected-error {{declaration of 'T' shadows template parameter}} }; struct D { struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} }; struct E { typedef int T; // expected-error {{declaration of 'T' shadows template parameter}} }; struct F { using T = int; // expected-error {{declaration of 'T' shadows template parameter}} }; struct G { int T; // expected-error {{declaration of 'T' shadows template parameter}} }; struct H { static int T; // expected-error {{declaration of 'T' shadows template parameter}} }; struct I { void T(); // expected-error {{declaration of 'T' shadows template parameter}} }; struct J { enum T { e }; // expected-error {{declaration of 'T' shadows template parameter}} }; struct K { enum E { T }; // expected-error {{declaration of 'T' shadows template parameter}} }; void a() { extern int T; // expected-error {{declaration of 'T' shadows template parameter}} } void b() { int T; // expected-error {{declaration of 'T' shadows template parameter}} } void c() { try {} catch (int T) {} // expected-error {{declaration of 'T' shadows template parameter}} } void d() { void T(); // expected-error {{declaration of 'T' shadows template parameter}} } void e() { namespace T = N; // expected-error {{declaration of 'T' shadows template parameter}} } // These cases are valid when 'T' is a non-type template parameter, as T // names an injected struct ::T, which doesn't shadow the template parameter. void f() { struct T *p; } friend struct T; }; template // expected-note {{declared here}} void f(int T) {} // expected-error {{declaration of 'T' shadows template parameter}} // FIXME: These are ill-formed: a template-parameter shall not have the same name as the template name. namespace A { template struct T {}; // expected-error{{declaration of 'T' shadows template parameter}} // expected-note@-1{{template parameter is declared here}} } namespace B { template void T() {} } namespace C { template int T; } namespace PR28023 { template // expected-note{{template parameter is declared here}} struct A { struct B { template friend struct V; // expected-error{{declaration of 'V' shadows template parameter}} }; }; A<0>::B a; }