FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.eh / rethrow1.C
blobef4dcb4f19db132291b1dbef238f69547943ad47
1 // Testcase for proper handling of rethrow.
3 #include <stdio.h>
5 int c, d;
7 struct A
9   int i;
10   A () { i = ++c; printf ("A() %d\n", i); }
11   A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); }
12   ~A() { printf ("~A() %d\n", i); ++d; }
15 int
16 main ()
18   try
19     {
20       try
21         {
22           printf ("Throwing 1...\n");
23           throw A();
24         }
25       catch (A)
26         {
27           try
28             {
29               printf ("Throwing 2...\n");
30               throw A();
31             }
32           catch (A)
33             {
34               printf ("Throwing 3...\n");
35               throw;
36             }
37         }
38     }
39   catch (A)
40     {
41       printf ("Caught.\n");
42     }
43   printf ("c == %d, d == %d\n", c, d);
44   return c != d;