libitm/testsuite/libitm.c++/eh-1.C
raw| 1 | // { dg-do run } |
| 2 | |
| 3 | extern "C" void abort (); |
| 4 | |
| 5 | int dothrow; |
| 6 | int g; |
| 7 | |
| 8 | static void f1() |
| 9 | { |
| 10 | g++; |
| 11 | if (dothrow) |
| 12 | throw 1; |
| 13 | } |
| 14 | |
| 15 | static void f2() |
| 16 | { |
| 17 | __transaction_atomic { |
| 18 | f1(); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | dothrow = 0; |
| 25 | f2(); |
| 26 | |
| 27 | dothrow = 1; |
| 28 | try { |
| 29 | f2(); |
| 30 | } catch (...) { |
| 31 | } |
| 32 | |
| 33 | if (g != 2) |
| 34 | abort (); |
| 35 | return 0; |
| 36 | } |