summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/eh/filter2.C
blob: fe87cc9a30817efba61d3bb513d310e42df64e06 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
// Test that terminate gets run when a catch filter fails to match while
// running destructors.  Original bug depended on a::~a being inlined.
// { dg-do run }
// { dg-options -O }

#include <exception>
#include <cstdlib>

struct e1 {};
struct e2 {};

struct a
{
  a () { }

  ~a ()
    {
      try
	{
	  throw e1();
	}
      catch (e2 &)
	{
        }
    }
};

void
ex_test ()
{
  a aa;
  try
    {
      throw e1 ();
    }
  catch (e2 &)
    {
    }
}

void my_terminate ()
{
  std::exit (0);
}

int
main ()
{
  std::set_terminate (my_terminate);

  try
    {
      ex_test ();
    }
  catch (...)
    {
    }
  abort ();
}