c++: fix arm-eabi crash building libstdc++ [PR105529]
commitbb2921ab84dba014f24be06663636c7fb1361474
authorJason Merrill <jason@redhat.com>
Mon, 9 May 2022 20:03:35 +0000 (9 16:03 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 10 May 2022 05:05:51 +0000 (10 01:05 -0400)
tree4916f6215202be7c12b436d43d04f050ec5f10ef
parent067fe66c8ba9b16feacf66fce9ae668091e42821
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.
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/optimize.cc
gcc/testsuite/g++.dg/cpp2a/constexpr-dtor13.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/constexpr-dtor14.C [new file with mode: 0644]