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.