gcc/testsuite/g++.dg/cpp2a/nontype-class29.C
raw| 1 | // PR c++/92948 - Fix class NTTP with template arguments. |
| 2 | // { dg-do run { target c++20 } } |
| 3 | |
| 4 | struct A { |
| 5 | int i; |
| 6 | constexpr A(int n) : i(n) { } |
| 7 | }; |
| 8 | |
| 9 | template<A a> |
| 10 | struct B { |
| 11 | static constexpr int i = a.i; |
| 12 | }; |
| 13 | |
| 14 | template<int X> |
| 15 | void foo() |
| 16 | { |
| 17 | B<X> b; |
| 18 | if (b.i != 42) |
| 19 | __builtin_abort (); |
| 20 | } |
| 21 | |
| 22 | int |
| 23 | main () |
| 24 | { |
| 25 | foo<42>(); |
| 26 | } |