1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
2 
3 template <typename T> struct A {
4   A(void *) {}
5   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.
9 A<int> instantiate1() { return {nullptr}; } // expected-note{{in instantiation of template class 'A<int>' requested here}}
10 
11 template <typename T> struct B {
12   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.
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 {
22   C(void *) {}
23   T S<T>{}; // expected-error{{member 'S' cannot have template arguments}}
24 };
25 // Don't crash.
26 C<int> instantiate3() { return {nullptr}; }
27 
28 template <typename T, template <typename> typename U> class D {
29 public:
30   D(void *) {}
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.
36 D<int, S> instantiate4() { return D<int, S>(nullptr); } // expected-note{{in instantiation of template class 'D<int, S>' requested here}}
37