diff options
author | Jason Merrill <jason@redhat.com> | 2022-02-25 09:58:47 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-05-04 09:54:02 -0400 |
commit | 9c6a4beeed572f9e235f881e00ad8c63b6bcc9df (patch) | |
tree | 356ad0232c7b7fa9861bd7124187ec792219087d /gcc/cp/typeck.cc | |
parent | eca04dc8555f5fae462fbd16386da9aaf38a0711 (diff) | |
download | gcc-9c6a4beeed572f9e235f881e00ad8c63b6bcc9df.zip gcc-9c6a4beeed572f9e235f881e00ad8c63b6bcc9df.tar.gz gcc-9c6a4beeed572f9e235f881e00ad8c63b6bcc9df.tar.bz2 |
c++: Remove cdtor_label
Jakub pointed out that cdtor_label is unnecessary, we should get all the
desired semantics with a normal return.
gcc/cp/ChangeLog:
* cp-tree.h (struct language_function): Remove x_cdtor_label.
(cdtor_label, LABEL_DECL_CDTOR): Remove.
* constexpr.cc (returns): Don't check LABEL_DECL_CDTOR.
(cxx_eval_constant_expression): Don't call returns.
* decl.cc (check_goto): Don't check cdtor_label.
(start_preparsed_function): And don't set it.
(finish_constructor_body, finish_destructor_body): Remove.
(finish_function_body): Don't call them.
* typeck.cc (check_return_expr): Handle cdtor_returns_this here.
* semantics.cc (finish_return_stmt): Not here.
Diffstat (limited to 'gcc/cp/typeck.cc')
-rw-r--r-- | gcc/cp/typeck.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index 0da6f24..57e55ed 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -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; |