| 1 |
// PR c++/91363 - P0960R3: Parenthesized initialization of aggregates. |
| 2 |
// { dg-do run { target c++20 } } |
| 3 |
|
| 4 |
struct A { |
| 5 |
int i = 0; |
| 6 |
int j = 0; |
| 7 |
}; |
| 8 |
|
| 9 |
struct B { |
| 10 |
A a; |
| 11 |
constexpr B() : a(1.1, 2) { } |
| 12 |
}; |
| 13 |
|
| 14 |
struct C { |
| 15 |
int i; |
| 16 |
}; |
| 17 |
|
| 18 |
struct E { |
| 19 |
C c; |
| 20 |
E() : c(1.2) { } |
| 21 |
}; |
| 22 |
|
| 23 |
struct F { |
| 24 |
char a[4]; |
| 25 |
}; |
| 26 |
|
| 27 |
struct G { |
| 28 |
F f; |
| 29 |
G() : f("yew") { } |
| 30 |
}; |
| 31 |
|
| 32 |
struct H { |
| 33 |
int i; |
| 34 |
int &&r; |
| 35 |
}; |
| 36 |
|
| 37 |
int f() { return 42; } |
| 38 |
|
| 39 |
struct I { |
| 40 |
H h; |
| 41 |
I() : h(1, f()) { } |
| 42 |
}; |
| 43 |
|
| 44 |
I i; // dangling ref to f(): |
| 45 |
// {.i=1, .r=(int &) &TARGET_EXPR <D.2118, f ()>} |
| 46 |
|
| 47 |
int |
| 48 |
main () |
| 49 |
{ |
| 50 |
B b; |
| 51 |
if (b.a.i != 1 || b.a.j != 2) |
| 52 |
__builtin_abort (); |
| 53 |
E e; |
| 54 |
if (e.c.i != 1) |
| 55 |
__builtin_abort (); |
| 56 |
} |