Debian Codegraph @

gcc/testsuite/g++.dg/DRs/dr2237.C

raw
1 // DR 2237 - Can a template-id name a constructor?
2
3 template<class T>
4 struct X {
5 X<T>(); // { dg-error "template-id not allowed for constructor" "" { target c++20 } }
6 X(int); // OK, injected-class-name used
7 ~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
8 };
9
10 // ill-formed since DR1435
11 template<typename T> X<T>::X<T>() {} // { dg-error "names the constructor|as no template constructors" }
12 template<typename T> X<T>::~X<T>() {} // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
13
14 struct Q {
15 // ill-formed since DR1435
16 template<typename T> friend X<T>::X<T>(); // { dg-error "names the constructor|as no template constructors" }
17 template<typename T> friend X<T>::~X<T>(); // { dg-error "template-id not allowed for destructor" "" { target c++20 } }
18 };