diff options
author | Jason Merrill <jason@redhat.com> | 2022-05-09 16:03:35 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-05-10 01:05:51 -0400 |
commit | bb2921ab84dba014f24be06663636c7fb1361474 (patch) | |
tree | 4916f6215202be7c12b436d43d04f050ec5f10ef /gcc/cp/optimize.cc | |
parent | 067fe66c8ba9b16feacf66fce9ae668091e42821 (diff) | |
download | gcc-bb2921ab84dba014f24be06663636c7fb1361474.zip gcc-bb2921ab84dba014f24be06663636c7fb1361474.tar.gz gcc-bb2921ab84dba014f24be06663636c7fb1361474.tar.bz2 |
c++: fix arm-eabi crash building libstdc++ [PR105529]
My recent change to cxx_eval_store_expression asserts that the target and
value can only end up having different types in the case of an empty base;
this was crashing arm-eabi compilers because in that ABI [cd]tors
return *this, and weren't converting it to void* first.
This also shares the 'return this' code between the three places it occurs.
Thanks to Marek for the tests.
PR c++/105529
gcc/cp/ChangeLog:
* decl.cc (maybe_return_this): Replace...
(finish_constructor_body, finish_destructor_body): ...these.
(finish_function_body): Call it.
* optimize.cc (build_delete_destructor_body): Call it.
* cp-tree.h (maybe_return_this): Declare.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constexpr-dtor13.C: New test.
* g++.dg/cpp2a/constexpr-dtor14.C: New test.
Diffstat (limited to 'gcc/cp/optimize.cc')
-rw-r--r-- | gcc/cp/optimize.cc | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/gcc/cp/optimize.cc b/gcc/cp/optimize.cc index 13ab8b7..5c134fd 100644 --- a/gcc/cp/optimize.cc +++ b/gcc/cp/optimize.cc @@ -163,14 +163,7 @@ build_delete_destructor_body (tree delete_dtor, tree complete_dtor) /* Return the address of the object. ??? How is it useful to return an invalid address? */ - if (targetm.cxx.cdtor_returns_this ()) - { - tree val = DECL_ARGUMENTS (delete_dtor); - suppress_warning (val, OPT_Wuse_after_free); - val = build2 (MODIFY_EXPR, TREE_TYPE (val), - DECL_RESULT (delete_dtor), val); - add_stmt (build_stmt (0, RETURN_EXPR, val)); - } + maybe_return_this (); } /* Return name of comdat group for complete and base ctor (or dtor) |