xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <exception>
4 
5 static void
eh_terminate()6 eh_terminate ()
7 {
8   printf ("CALLING TERMINATE\n");
9   exit (1);
10 }
11 
12 void
eh_test(int level)13 eh_test (int level)
14 {
15   try
16     {
17       if (level < 2)
18 	eh_test (level + 1);
19       else
20 	{
21 	  printf ("%d: Throwing\n", level);
22 	  throw (level);
23 	}
24     }
25   catch (int &x)
26     {
27       printf ("%d: Got level %d\n",
28 	      level, x);
29 
30       if (level > 0)
31 	throw;
32     }
33 }
34 
main()35 int main ()
36 {
37   std::set_terminate (&eh_terminate);
38   eh_test (0);
39 }
40