summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/eh/filter2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/eh/filter2.C')
-rw-r--r--gcc/testsuite/g++.dg/eh/filter2.C59
1 files changed, 59 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/eh/filter2.C b/gcc/testsuite/g++.dg/eh/filter2.C
new file mode 100644
index 000000000..fe87cc9a3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/filter2.C
@@ -0,0 +1,59 @@
+// Test that terminate gets run when a catch filter fails to match while
+// running destructors. Original bug depended on a::~a being inlined.
+// { dg-do run }
+// { dg-options -O }
+
+#include <exception>
+#include <cstdlib>
+
+struct e1 {};
+struct e2 {};
+
+struct a
+{
+ a () { }
+
+ ~a ()
+ {
+ try
+ {
+ throw e1();
+ }
+ catch (e2 &)
+ {
+ }
+ }
+};
+
+void
+ex_test ()
+{
+ a aa;
+ try
+ {
+ throw e1 ();
+ }
+ catch (e2 &)
+ {
+ }
+}
+
+void my_terminate ()
+{
+ std::exit (0);
+}
+
+int
+main ()
+{
+ std::set_terminate (my_terminate);
+
+ try
+ {
+ ex_test ();
+ }
+ catch (...)
+ {
+ }
+ abort ();
+}