summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/eh/cond4.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/eh/cond4.C')
-rw-r--r--gcc/testsuite/g++.dg/eh/cond4.C32
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/eh/cond4.C b/gcc/testsuite/g++.dg/eh/cond4.C
new file mode 100644
index 000000000..a8d1cfbf3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/cond4.C
@@ -0,0 +1,32 @@
+// Runtime version of cond3.C. We call terminate when the A cleanup throws
+// because we've already initialized the exception object.
+// { dg-do run }
+
+#include <exception>
+#include <cstdlib>
+
+void my_terminate ()
+{
+ std::exit (0);
+}
+
+struct A {
+ A(int) { }
+ ~A() { throw 1; };
+};
+struct B {
+ B(A) { }
+ ~B() { }
+};
+bool b;
+
+int main()
+{
+ std::set_terminate (my_terminate);
+ try
+ {
+ throw b ? B(1) : B(1);
+ }
+ catch (...) { }
+ return 1;
+}