PR c++/85553
[official-gcc.git] / gcc / testsuite / g++.dg / ext / desig2.C
blobb117878f5a788382054128ec6558f40daa84e307
1 // Test for C99-style designated array initializer
3 union U
5   long l;
6   const char *p;
7 };
9 __extension__ U u = { .p = "" };
11 __extension__ int i[4] = { [0] = 1, [1] = 2 };
13 // Currently, except for unions, the C++ front end only supports
14 // designators that designate the element that would have been initialized
15 // anyway, except that C++2A designators can skip over some direct
16 // non-static data members.  While that's true, make sure that we get
17 // a sorry rather than bad code.
19 struct A
21   int i;
22   int j;
25 __extension__ A a = { .j = 1 };
26 __extension__ A b = { .j = 2, .i = 1 }; // { dg-error "designator order for field 'A::i' does not match declaration order in 'A'" }
27 __extension__ int j[2] = { [1] = 1 }; // { dg-message "non-trivial" }