2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.eh / rethrow1.C
blob286f1bd252886c5f7a9e77452e56a7b3ae39ec6d
1 // { dg-do run  }
2 // Testcase for proper handling of rethrow.
4 #include <stdio.h>
6 int c, d;
8 struct A
10   int i;
11   A () { i = ++c; printf ("A() %d\n", i); }
12   A (const A&) { i = ++c; printf ("A(const A&) %d\n", i); }
13   ~A() { printf ("~A() %d\n", i); ++d; }
16 int
17 main ()
19   try
20     {
21       try
22         {
23           printf ("Throwing 1...\n");
24           throw A();
25         }
26       catch (A)
27         {
28           try
29             {
30               printf ("Throwing 2...\n");
31               throw A();
32             }
33           catch (A)
34             {
35               printf ("Throwing 3...\n");
36               throw;
37             }
38         }
39     }
40   catch (A)
41     {
42       printf ("Caught.\n");
43     }
44   printf ("c == %d, d == %d\n", c, d);
45   return c != d;