c++, coroutines: Handle allocation fail returns [PR121219].
The current implementation was returning the result of the g_r_o_o_a_f
call independently of the return expressions for 'normal' cases.
This prevents the NVRO that we need to guarantee copy elision for the
ramp return values - when these are initialised from a temporary of the
same type.
The solution here reorders the code so that the regular return expression
appears before the allocation-failed case. Ensure that the g_r_o and
associated code appears in a distinct scope. These steps are to meet the
constaints of NRV.
PR c++/121219
gcc/cp/ChangeLog:
* coroutines.cc
(cp_coroutine_transform::build_ramp_function): Reorder the return
expressions for the 'normal' and 'allocation failed' cases so that
NRV constraints are met.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/torture/pr121219.C: New test.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit
a2775feb7c7de9f21f79052e2b6a752a3eb08f07)