summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.eh/spec2.C
blob: 5c7a91399e9c48b37b7c8372f178c628bf5538ed (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 2: the second throw succeeds.

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

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

void
f () throw (int, 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 0;
    }
  catch (std::bad_exception)
    {
      return 4;
    }
  return 5;
}