aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/eh23.C
blob: 17a9669388f3bbda626ca16a9abe16b3f283eaef (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
// Special g++ Options: -fexceptions
// excess errors test - XFAIL a29k-*-* sparc64-*-elf sh-*-* arm-*-pe**-*

#include <exception>

struct double_fault { };
int fault_now;

class E {
public:
  E() { }
  E(const E&) {
    if (fault_now)
      throw double_fault();
  }
};

void foo() {
  try {
    throw E();
  } catch (...) {
    fault_now = 1;
    throw;
  }
}

void bar() {
  try {
    foo();
  } catch (E e) {	// double fault here
  }
}

void my_terminate() {
  exit (0);		// double faults should call terminate
}

main() {
  set_terminate (my_terminate);
  try {
    bar();
  } catch (...) {
    return 1;
  }
  return 1;
}