| 1 |
// Test throwing an exception whose constructor might throw. This tests that |
| 2 |
// _cxa_free_exception is instrumented. |
| 3 |
|
| 4 |
// { dg-do run } |
| 5 |
// { dg-options "-fgnu-tm" } |
| 6 |
|
| 7 |
void __attribute__ ((transaction_pure,noinline)) dontoptimize (int *i) |
| 8 |
{ } |
| 9 |
|
| 10 |
struct test |
| 11 |
{ |
| 12 |
int* data; |
| 13 |
test (int i) |
| 14 |
{ |
| 15 |
// new may throw |
| 16 |
data = new int[1]; |
| 17 |
data[0] = i; |
| 18 |
dontoptimize (data); |
| 19 |
} |
| 20 |
test (const test& t) : test (t.data[0]) |
| 21 |
{ } |
| 22 |
~test () |
| 23 |
{ |
| 24 |
delete data; |
| 25 |
} |
| 26 |
bool operator !=(const test& other) |
| 27 |
{ |
| 28 |
return data[0] != other.data[0]; |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
int main() |
| 33 |
{ |
| 34 |
try |
| 35 |
{ |
| 36 |
atomic_commit |
| 37 |
{ |
| 38 |
throw test(23); |
| 39 |
} |
| 40 |
} |
| 41 |
catch (test ex) |
| 42 |
{ |
| 43 |
if (ex.data[0] != 23) __builtin_abort (); |
| 44 |
} |
| 45 |
return 0; |
| 46 |
} |