summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.eh/spec3.C
blob: 6239270ee370fd07ae9d51bd8fe7251b46339edd (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
// { dg-do run  }
// Testing exception specifications.
// Test 3: the bad_exception throw succeeds.

#include <stdlib.h>
#include <exception>

void my_term ()  { exit (1); }
void my_unexp () { throw 42; }

void
f () throw (std::bad_exception)
{
  throw 'a';
}

int main ()
{
  std::set_terminate (my_term);
  std::set_unexpected (my_unexp);

  try
    {
      f ();
    }
  catch (char)
    {
      return 2;
    }
  catch (int)
    {
      return 3;
    }
  catch (std::bad_exception)
    {
      return 0;
    }
  return 5;
}