summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.eh/rethrow3.C
blob: 952318b80126ce397fe7036ec364aa0e0715751f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// { dg-do run  }
#include <stdio.h>
#include <stdlib.h>
#include <exception>

static void
eh_terminate ()
{
  printf ("CALLING TERMINATE\n");
  exit (1);
}

void
eh_test (int level)
{
  try
    {
      if (level < 2)
	eh_test (level + 1);
      else
	{
	  printf ("%d: Throwing\n", level);
	  throw (level);
	}
    }
  catch (int &x)
    {
      printf ("%d: Got level %d\n",
	      level, x);

      if (level > 0)
	throw;
    }
}

int main ()
{
  std::set_terminate (&eh_terminate);
  eh_test (0);
}