[gcc r10-5989] Revert "PR c++/33799 - destroy return value if local cleanup throws."

Jason Merrill jason@gcc.gnu.org
Wed Jan 15 20:14:00 GMT 2020


https://gcc.gnu.org/g:299ddc612136421f1d9865ea4f2f84f7e3791824

commit r10-5989-g299ddc612136421f1d9865ea4f2f84f7e3791824
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 15 14:13:13 2020 -0500

    Revert "PR c++/33799 - destroy return value if local cleanup throws."
    
    This change was blocking the coroutines merge, so I'm backing it out for now
    to adjust my approach.
    
    This reverts commit 7c82dd6c02d44d9d2cd84dda137c00b1a3cd6c90.

Diff:
---
 gcc/cp/ChangeLog                  |  6 ++++++
 gcc/cp/cp-tree.h                  |  7 -------
 gcc/cp/decl.c                     | 14 --------------
 gcc/cp/typeck.c                   |  9 ---------
 gcc/testsuite/g++.dg/eh/return1.C |  2 +-
 5 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 95eb2a7..4a15579 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
 2020-01-15  Jason Merrill  <jason@redhat.com>
 
+	Revert
+	PR c++/33799 - destroy return value if local cleanup throws.
+	* cp-tree.h (current_retval_sentinel): New macro.
+	* decl.c (start_preparsed_function): Set up cleanup for retval.
+	* typeck.c (check_return_expr): Set current_retval_sentinel.
+
 	PR c++/93257 - consteval void function.
 	* constexpr.c (verify_constant): Allow void_node.
 
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4e26acc..2b08d1b 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1954,13 +1954,6 @@ struct GTY(()) language_function {
 
 #define current_vtt_parm cp_function_chain->x_vtt_parm
 
-/* A boolean flag to control whether we need to clean up the return value if a
-   local destructor throws.  Only used in functions that return by value a
-   class with a destructor.  Which 'tors don't, so we can use the same
-   field as current_vtt_parm.  */
-
-#define current_retval_sentinel current_vtt_parm
-
 /* Set to 0 at beginning of a function definition, set to 1 if
    a return statement that specifies a return value is seen.  */
 
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 52da0de..094e32e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -16418,20 +16418,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
   if (!DECL_OMP_DECLARE_REDUCTION_P (decl1))
     start_lambda_scope (decl1);
 
-  /* If cleaning up locals on return throws an exception, we need to destroy
-     the return value that we just constructed.  */
-  if (!processing_template_decl
-      && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (TREE_TYPE (decl1))))
-    {
-      tree retval = DECL_RESULT (decl1);
-      tree dtor = build_cleanup (retval);
-      current_retval_sentinel = get_temp_regvar (boolean_type_node,
-						 boolean_false_node);
-      dtor = build3 (COND_EXPR, void_type_node, current_retval_sentinel,
-		     dtor, void_node);
-      push_cleanup (retval, dtor, /*eh-only*/true);
-    }
-
   return true;
 }
 
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 2be4e24..8955442 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -10090,15 +10090,6 @@ check_return_expr (tree retval, bool *no_warning)
   if (retval && retval != result)
     retval = build2 (INIT_EXPR, TREE_TYPE (result), result, retval);
 
-  if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (valtype)
-      /* FIXME doesn't work with deduced return type.  */
-      && current_retval_sentinel)
-    {
-      tree set = build2 (MODIFY_EXPR, boolean_type_node,
-			 current_retval_sentinel, boolean_true_node);
-      retval = build2 (COMPOUND_EXPR, void_type_node, retval, set);
-    }
-
   return retval;
 }
 
diff --git a/gcc/testsuite/g++.dg/eh/return1.C b/gcc/testsuite/g++.dg/eh/return1.C
index 7469d31..ca0b804 100644
--- a/gcc/testsuite/g++.dg/eh/return1.C
+++ b/gcc/testsuite/g++.dg/eh/return1.C
@@ -1,5 +1,5 @@
 // PR c++/33799
-// { dg-do run }
+// { dg-do run { xfail *-*-* } }
 
 extern "C" void abort();



More information about the Gcc-cvs mailing list