1// RUN: %clang_cc1 -verify %s -fcxx-exceptions -std=c++1y
2
3template<typename T, // expected-note {{declared here}}
4         typename T> struct X {}; // expected-error {{declaration of 'T' shadows template parameter}}
5
6template<typename T> struct Y { // expected-note 15{{declared here}}
7  template<typename T> struct A {}; // expected-error {{declaration of 'T' shadows template parameter}}
8
9  struct B {
10    template<typename> struct T {}; // FIXME: desired-error {{declaration of 'T' shadows template parameter}}
11  };
12  struct C {
13    template<typename> void T(); // expected-error {{declaration of 'T' shadows template parameter}}
14  };
15  struct D {
16    struct T {}; // expected-error {{declaration of 'T' shadows template parameter}}
17  };
18  struct E {
19    typedef int T; // expected-error {{declaration of 'T' shadows template parameter}}
20  };
21  struct F {
22    using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
23  };
24  struct G {
25    int T; // expected-error {{declaration of 'T' shadows template parameter}}
26  };
27  struct H {
28    static int T; // expected-error {{declaration of 'T' shadows template parameter}}
29  };
30  struct I {
31    void T(); // expected-error {{declaration of 'T' shadows template parameter}}
32  };
33  struct J {
34    enum T { e }; // expected-error {{declaration of 'T' shadows template parameter}}
35  };
36  struct K {
37    enum E { T }; // expected-error {{declaration of 'T' shadows template parameter}}
38  };
39
40  void a() {
41    extern int T; // expected-error {{declaration of 'T' shadows template parameter}}
42  }
43  void b() {
44    int T; // expected-error {{declaration of 'T' shadows template parameter}}
45  }
46  void c() {
47    try {}
48    catch (int T) {} // expected-error {{declaration of 'T' shadows template parameter}}
49  }
50  void d() {
51    void T(); // expected-error {{declaration of 'T' shadows template parameter}}
52  }
53
54  friend struct T; // expected-error {{declaration of 'T' shadows template parameter}}
55};
56
57template<typename T> // expected-note {{declared here}}
58void f(int T) {} // expected-error {{declaration of 'T' shadows template parameter}}
59
60// FIXME: These are ill-formed: a template-parameter shall not have the same name as the template name.
61namespace A {
62  template<typename T> struct T {};
63}
64namespace B {
65  template<typename T> void T() {}
66}
67namespace C {
68  template<typename T> int T;
69}
70