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.
#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. */
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;
}
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;
}
// PR c++/33799
-// { dg-do run }
+// { dg-do run { xfail *-*-* } }
extern "C" void abort();