aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/desig7.C
blob: 2865014f591f854072bde08c7114f1f1cb1f0372 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// PR c++/84874
// { dg-do run { target c++11 } }
// { dg-options "" }

struct A { int a, b; };
struct B { A d; };

void
foo (B *x)
{
  *x = { .d = { .b = 5 } };
}

void
bar (A *x)
{
  *x = { .b = 6 };
}

int
main ()
{
  B b = { { 2, 3 } };
  foo (&b);
  if (b.d.a != 0 || b.d.b != 5)
    __builtin_abort ();
  b.d.a = 8;
  bar (&b.d);
  if (b.d.a != 0 || b.d.b != 6)
    __builtin_abort ();
}