1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
2
3 template <typename T> struct A {
AA4 A(void *) {}
TA5 T(A<T>){}; // expected-error{{member 'A' cannot have template arguments}}\
6 // expected-error2{{member 'A' has the same name as its class}}
7 };
8 // Don't crash.
instantiate1()9 A<int> instantiate1() { return {nullptr}; } // expected-note{{in instantiation of template class 'A<int>' requested here}}
10
11 template <typename T> struct B {
BB12 B(void *) {}
13 T B<T>{}; // expected-error{{member 'B' cannot have template arguments}}\
14 // expected-error2{{member 'B' has the same name as its class}}
15 };
16 // Don't crash.
instantiate2()17 B<int> instantiate2() { return {nullptr}; } // expected-note{{in instantiation of template class 'B<int>' requested here}}
18
19 template <typename T> struct S {};
20
21 template <typename T> struct C {
CC22 C(void *) {}
23 T S<T>{}; // expected-error{{member 'S' cannot have template arguments}}
24 };
25 // Don't crash.
instantiate3()26 C<int> instantiate3() { return {nullptr}; }
27
28 template <typename T, template <typename> typename U> class D {
29 public:
D(void *)30 D(void *) {}
T(D<T,U<T>>)31 T(D<T, U<T>>) {} // expected-error{{member 'D' cannot have template arguments}}\
32 // expected-error{{expected ';' at end of declaration list}}\
33 // expected-error2{{member 'D' has the same name as its class}}
34 };
35 // Don't crash.
instantiate4()36 D<int, S> instantiate4() { return D<int, S>(nullptr); } // expected-note{{in instantiation of template class 'D<int, S>' requested here}}
37