| 1 |
/* N3356 - if declarations. */ |
| 2 |
/* PR c/117019 */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-options "-std=c2y" } */ |
| 5 |
|
| 6 |
int g; |
| 7 |
int get () { ++g; return 42; } |
| 8 |
|
| 9 |
struct S { int i; }; |
| 10 |
|
| 11 |
int |
| 12 |
main () |
| 13 |
{ |
| 14 |
if (auto x = get (); get (), x); |
| 15 |
if (g != 2) |
| 16 |
__builtin_abort (); |
| 17 |
|
| 18 |
switch (auto x = get (); get (), x); |
| 19 |
if (g != 4) |
| 20 |
__builtin_abort (); |
| 21 |
|
| 22 |
if (struct S s = { 42 }; s.i != 42) |
| 23 |
__builtin_abort (); |
| 24 |
|
| 25 |
if (int i = 42) |
| 26 |
{ |
| 27 |
i = 0; |
| 28 |
if (int j = 42) |
| 29 |
j = 0; |
| 30 |
else |
| 31 |
j = 42; |
| 32 |
} |
| 33 |
else |
| 34 |
i = 42; |
| 35 |
} |