summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/eh/unexpected1.C
blob: e5982ffacc5cced8a8228fd0b48d97238098202b (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
41
42
43
44
45
46
// PR 3719
// Test that an unexpected handler can rethrow to categorize.
// { dg-do run }

#include <exception>

extern "C" void abort ();

struct One { };
struct Two { };

static void
handle_unexpected ()
{
  try
  {
    throw;
  }
  catch (One &)
  {
    throw Two ();
  }
}

static void
doit () throw (Two)
{
  throw One ();
}

int main ()
{
  std::set_unexpected (handle_unexpected);

  try
  {
    doit ();
  }
  catch (Two &)
  {
  }
  catch (...)
  {
    abort ();
  }
}