| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "" } |
| 3 |
|
| 4 |
struct S { int a, b, c; }; |
| 5 |
|
| 6 |
S a = { 1, 2, 3 }; |
| 7 |
S b = { .a = 1, .b = 2, .c = 3 }; |
| 8 |
S c = { 1, .b = 2, .c = 3 }; // { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++20 } } |
| 9 |
S d = { .a = 1, 2, 3 }; // { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++20 } } |
| 10 |
S e = { .b = 1, .b = 2 }; // { dg-error "designator used multiple times in the same initializer list" } |
| 11 |
|
| 12 |
#if __cplusplus > 201103L |
| 13 |
template <int... N> |
| 14 |
void |
| 15 |
foo () |
| 16 |
{ |
| 17 |
S f = { .a = N... }; // { dg-error "'...' not allowed in designated initializer list" "" { target c++20 } } |
| 18 |
} |
| 19 |
#endif |