OSDN Git Service

PR c++/24996
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 12 Feb 2006 16:02:00 +0000 (16:02 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 12 Feb 2006 16:02:00 +0000 (16:02 +0000)
        * except.c (build_throw): Add a CLEANUP_POINT_EXPR inside the
        TRY_CATCH_EXPR or MUST_NOT_THROW_EXPR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110889 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/testsuite/g++.dg/eh/cond3.C [new file with mode: 0644]

index c85115e..cbab739 100644 (file)
@@ -1,3 +1,9 @@
+2006-02-12  Jason Merrill  <jason@redhat.com>
+
+       PR c++/24996
+       * except.c (build_throw): Add a CLEANUP_POINT_EXPR inside the 
+       TRY_CATCH_EXPR or MUST_NOT_THROW_EXPR.
+
 2006-02-10  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        * class.c (debug_class): Remove extern.
index be7208e..9041342 100644 (file)
@@ -722,6 +722,7 @@ build_throw (tree exp)
       temp_expr = NULL_TREE;
       stabilize_init (exp, &temp_expr);
 
+      exp = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (exp), exp);
       if (elided)
        exp = build2 (TRY_CATCH_EXPR, void_type_node, exp,
                      do_free_exception (ptr));
diff --git a/gcc/testsuite/g++.dg/eh/cond3.C b/gcc/testsuite/g++.dg/eh/cond3.C
new file mode 100644 (file)
index 0000000..0af4ecd
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/24996
+// Bug: the cleanup for the A temporary was confusing the gimplifier
+// because of the TRY_CATCH_EXPR for the exception object.
+
+struct A { A(int); ~A(); };
+struct B { B(A); ~B(); };
+void foo(bool b)
+{
+  throw b ? B(1) : B(1);
+}