Update ChangeLog and version files for release
[official-gcc.git] / libitm / testsuite / libitm.c++ / eh-5.C
blobae38bbaced5e6bf445fe9893a1eb406f80893475
1 // Test throwing an exception whose constructor might throw.  This tests that
2 // _cxa_free_exception is instrumented.
4 // { dg-do run }
5 // { dg-options "-fgnu-tm" }
7 void __attribute__ ((transaction_pure,noinline)) dontoptimize (int *i)
8 { }
10 struct test
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   }
32 int main()
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;