PR c++/84874
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / desig7.C
blob2865014f591f854072bde08c7114f1f1cb1f0372
1 // PR c++/84874
2 // { dg-do run { target c++11 } }
3 // { dg-options "" }
5 struct A { int a, b; };
6 struct B { A d; };
8 void
9 foo (B *x)
11   *x = { .d = { .b = 5 } };
14 void
15 bar (A *x)
17   *x = { .b = 6 };
20 int
21 main ()
23   B b = { { 2, 3 } };
24   foo (&b);
25   if (b.d.a != 0 || b.d.b != 5)
26     __builtin_abort ();
27   b.d.a = 8;
28   bar (&b.d);
29   if (b.d.a != 0 || b.d.b != 6)
30     __builtin_abort ();