| 1 |
// { dg-do compile { target c++17 } } |
| 2 |
|
| 3 |
extern int foo (void); |
| 4 |
extern void bar (int), die (void); |
| 5 |
|
| 6 |
void |
| 7 |
f (void) |
| 8 |
{ |
| 9 |
if (auto i = foo (); i != -1) |
| 10 |
bar (1); |
| 11 |
else |
| 12 |
die (); |
| 13 |
|
| 14 |
i = 10; // { dg-error "not declared" } |
| 15 |
} |
| 16 |
|
| 17 |
void |
| 18 |
f2 (void) |
| 19 |
{ |
| 20 |
switch (auto i = foo (); i) |
| 21 |
{ |
| 22 |
case 0: |
| 23 |
bar (i + 1); |
| 24 |
break; |
| 25 |
case 1: |
| 26 |
bar (i + 10); |
| 27 |
break; |
| 28 |
default: |
| 29 |
break; |
| 30 |
} |
| 31 |
|
| 32 |
i = 10; // { dg-error "not declared" } |
| 33 |
} |
| 34 |
|
| 35 |
void |
| 36 |
f3 (void) |
| 37 |
{ |
| 38 |
if constexpr (constexpr auto i = sizeof (long); i < 2) |
| 39 |
die (); |
| 40 |
i = 4; // { dg-error "not declared" } |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
void |
| 45 |
f4 (void) |
| 46 |
{ |
| 47 |
{ |
| 48 |
if (auto i = foo (); i > -1) |
| 49 |
{ |
| 50 |
if (i > 5) |
| 51 |
bar (i); |
| 52 |
if (auto j = foo (); true) |
| 53 |
j++; |
| 54 |
j--; // { dg-error "not declared" } |
| 55 |
} |
| 56 |
i = 10; // { dg-error "not declared" } |
| 57 |
} |
| 58 |
i = 10; // { dg-error "not declared" } |
| 59 |
} |