| 1 |
// PR c++/91360 - Implement C++20 P1143R2: constinit |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
// From PR83428. |
| 4 |
|
| 5 |
struct S1 |
| 6 |
{ |
| 7 |
constexpr S1 (); |
| 8 |
int m_i; |
| 9 |
}; |
| 10 |
|
| 11 |
struct alignas(64) S2 |
| 12 |
{ |
| 13 |
constexpr S2 () |
| 14 |
: m_tabS1() // { dg-error "used before its definition" } |
| 15 |
{} |
| 16 |
|
| 17 |
S1 m_tabS1[7]; |
| 18 |
}; |
| 19 |
|
| 20 |
constinit S2 objX; // { dg-error ".constinit. variable .objX. does not have a constant initializer" } |
| 21 |
// { dg-message "in .constexpr. expansion of" "" { target *-*-* } .-1 } |
| 22 |
|
| 23 |
constexpr S1::S1 () |
| 24 |
: m_i(14) |
| 25 |
{} |