Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/nontype-class68.C

raw
1 // PR c++/113800
2 // { dg-do compile { target c++20 } }
3 // From [temp.arg.nontype].
4
5 template<auto n> struct B { /* ... */ };
6 B<5> b1; // OK, template parameter type is int
7 B<'a'> b2; // OK, template parameter type is char
8 B<2.5> b3; // OK, template parameter type is double
9 B<void(0)> b4; // { dg-error ".void. is not a valid type for a template non-type parameter" }
10
11 template<int i> struct C { /* ... */ };
12 C<{ 42 }> c1; // OK
13
14 struct J1 {
15 J1 *self = this;
16 };
17 B<J1{}> j1; // { dg-error "not a constant expression" }
18
19 struct J2 {
20 J2 *self = this;
21 constexpr J2() {}
22 constexpr J2(const J2&) {}
23 };
24 B<J2{}> j2; // { dg-error "not a constant expression" }