[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / injected-class-name.cpp
blob93a7231b8c7b7ac0c81a03930f881fc0904b0fd4
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 template<typename T>
3 struct X {
4 X<T*> *ptr;
5 };
7 X<int> x;
9 template<>
10 struct X<int***> {
11 typedef X<int***> *ptr;
14 X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name}}
15 void f() {
16 X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name}}
19 // [temp.local]p1:
21 // FIXME: test template template parameters
22 template<typename T, typename U>
23 struct X0 {
24 typedef T type;
25 typedef U U_type;
26 typedef U_type U_type2;
28 void f0(const X0&); // expected-note{{here}}
29 void f0(X0&);
30 void f0(const X0<T, U>&); // expected-error{{redecl}}
32 void f1(const X0&); // expected-note{{here}}
33 void f1(X0&);
34 void f1(const X0<type, U_type2>&); // expected-error{{redecl}}
36 void f2(const X0&); // expected-note{{here}}
37 void f2(X0&);
38 void f2(const ::X0<type, U_type2>&); // expected-error{{redecl}}
41 template<typename T, T N>
42 struct X1 {
43 void f0(const X1&); // expected-note{{here}}
44 void f0(X1&);
45 void f0(const X1<T, N>&); // expected-error{{redecl}}
48 namespace pr6326 {
49 template <class T> class A {
50 friend class A;
52 template class A<int>;
55 namespace ForwardDecls {
56 template<typename T>
57 struct X;
59 template<typename T>
60 struct X {
61 typedef T foo;
62 typedef X<T> xt;
63 typename xt::foo *t;
67 namespace ConflictingRedecl {
68 template<typename> struct Nested {
69 template<typename> struct Nested; // expected-error {{member 'Nested' has the same name as its class}}