@@ -543,7 +543,6 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
DECL_CONSTRAINT_VAR_P (in a PARM_DECL)
TEMPLATE_DECL_COMPLEX_ALIAS_P (in TEMPLATE_DECL)
DECL_INSTANTIATING_NSDMI_P (in a FIELD_DECL)
- LABEL_DECL_CDTOR (in LABEL_DECL)
USING_DECL_UNRELATED_P (in USING_DECL)
3: DECL_IN_AGGR_P.
4: DECL_C_BIT_FIELD (in a FIELD_DECL)
@@ -2057,7 +2056,6 @@ struct named_label_hash : ggc_remove <named_label_entry *>
struct GTY(()) language_function {
struct c_language_function base;
- tree x_cdtor_label;
tree x_current_class_ptr;
tree x_current_class_ref;
tree x_eh_spec_block;
@@ -2091,13 +2089,6 @@ struct GTY(()) language_function {
#define cp_function_chain (cfun->language)
-/* In a constructor destructor, the point at which all derived class
- destroying/construction has been done. I.e., just before a
- constructor returns, or before any base class destroying will be done
- in a destructor. */
-
-#define cdtor_label cp_function_chain->x_cdtor_label
-
/* When we're processing a member function, current_class_ptr is the
PARM_DECL for the `this' pointer. The current_class_ref is an
expression for `*this'. */
@@ -4278,11 +4269,6 @@ get_vec_init_expr (tree t)
#define DECL_LOCAL_DECL_ALIAS(NODE) \
DECL_ACCESS ((gcc_checking_assert (DECL_LOCAL_DECL_P (NODE)), NODE))
-/* Nonzero if NODE is the target for genericization of 'return' stmts
- in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */
-#define LABEL_DECL_CDTOR(NODE) \
- DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE))
-
/* True if NODE was declared with auto in its return type, but it has
started compilation and so the return type might have been changed by
return type deduction; its declared return type should be found in
@@ -6060,9 +6060,7 @@ static bool
returns (tree *jump_target)
{
return *jump_target
- && (TREE_CODE (*jump_target) == RETURN_EXPR
- || (TREE_CODE (*jump_target) == LABEL_DECL
- && LABEL_DECL_CDTOR (*jump_target)));
+ && TREE_CODE (*jump_target) == RETURN_EXPR;
}
static bool
@@ -7473,9 +7471,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case GOTO_EXPR:
if (breaks (&TREE_OPERAND (t, 0))
- || continues (&TREE_OPERAND (t, 0))
- /* Allow for jumping to a cdtor_label. */
- || returns (&TREE_OPERAND (t, 0)))
+ || continues (&TREE_OPERAND (t, 0)))
*jump_target = TREE_OPERAND (t, 0);
else
{
@@ -3613,11 +3613,6 @@ check_goto (tree decl)
if (TREE_CODE (decl) != LABEL_DECL)
return;
- /* We didn't record any information about this label when we created it,
- and there's not much point since it's trivial to analyze as a return. */
- if (decl == cdtor_label)
- return;
-
hashval_t hash = IDENTIFIER_HASH_VALUE (DECL_NAME (decl));
named_label_entry **slot
= named_labels->find_slot_with_hash (DECL_NAME (decl), hash, NO_INSERT);
@@ -17325,14 +17320,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
++function_depth;
- if (DECL_DESTRUCTOR_P (decl1)
- || (DECL_CONSTRUCTOR_P (decl1)
- && targetm.cxx.cdtor_returns_this ()))
- {
- cdtor_label = create_artificial_label (input_location);
- LABEL_DECL_CDTOR (cdtor_label) = true;
- }
-
start_fname_decls ();
store_parm_decls (current_function_parms);
@@ -17503,9 +17490,6 @@ finish_constructor_body (void)
if (targetm.cxx.cdtor_returns_this ())
{
- /* Any return from a constructor will end up here. */
- add_stmt (build_stmt (input_location, LABEL_EXPR, cdtor_label));
-
val = DECL_ARGUMENTS (current_function_decl);
suppress_warning (val, OPT_Wuse_after_free);
val = build2 (MODIFY_EXPR, TREE_TYPE (val),
@@ -17592,10 +17576,6 @@ finish_destructor_body (void)
{
tree exprstmt;
- /* Any return from a destructor will end up here; that way all base
- and member cleanups will be run when the function returns. */
- add_stmt (build_stmt (input_location, LABEL_EXPR, cdtor_label));
-
if (targetm.cxx.cdtor_returns_this ())
{
tree val;
@@ -1238,17 +1238,6 @@ finish_return_stmt (tree expr)
{
if (warn_sequence_point)
verify_sequence_points (expr);
-
- if (DECL_DESTRUCTOR_P (current_function_decl)
- || (DECL_CONSTRUCTOR_P (current_function_decl)
- && targetm.cxx.cdtor_returns_this ()))
- {
- /* Similarly, all destructors must run destructors for
- base-classes before returning. So, all returns in a
- destructor get sent to the DTOR_LABEL; finish_function emits
- code to return a value there. */
- return finish_goto_stmt (cdtor_label);
- }
}
r = build_stmt (input_location, RETURN_EXPR, expr);
@@ -10447,7 +10447,11 @@ check_return_expr (tree retval, bool *no_warning)
{
if (retval)
error_at (loc, "returning a value from a destructor");
- return NULL_TREE;
+
+ if (targetm.cxx.cdtor_returns_this ())
+ retval = current_class_ptr;
+ else
+ return NULL_TREE;
}
else if (DECL_CONSTRUCTOR_P (current_function_decl))
{
@@ -10458,7 +10462,11 @@ check_return_expr (tree retval, bool *no_warning)
else if (retval)
/* You can't return a value from a constructor. */
error_at (loc, "returning a value from a constructor");
- return NULL_TREE;
+
+ if (targetm.cxx.cdtor_returns_this ())
+ retval = current_class_ptr;
+ else
+ return NULL_TREE;
}
const tree saved_retval = retval;