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