aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.eh/spec4.C
blob: adcf6751b1ae4270e3986307270b579eb71472c8 (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
// Testing exception specifications.
// Test 4: all throws fail, call terminate.

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

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

void
f () throw (short)
{
  throw 'a';
}

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 4;
    }
  return 5;
}