gcc/testsuite/g++.dg/eh/goto1.C
raw| 1 | extern "C" void abort (); |
| 2 | |
| 3 | static int count; |
| 4 | |
| 5 | struct S { |
| 6 | S() { ++count; } |
| 7 | ~S() { --count; } |
| 8 | }; |
| 9 | |
| 10 | int foo(int p) |
| 11 | { |
| 12 | S s1; |
| 13 | { |
| 14 | S s2; |
| 15 | if (p) |
| 16 | goto L; |
| 17 | else |
| 18 | return 1; |
| 19 | } |
| 20 | foo (p); |
| 21 | L: |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | int main() |
| 26 | { |
| 27 | foo(0); |
| 28 | if (count != 0) |
| 29 | abort (); |
| 30 | foo(1); |
| 31 | if (count != 0) |
| 32 | abort (); |
| 33 | return 0; |
| 34 | } |