coroutines: Only set parm copy guard vars if we have exceptions [PR 102454].
authorIain Sandoe <iain@sandoe.co.uk>
Mon, 27 Sep 2021 19:21:40 +0000 (20:21 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 28 Sep 2021 18:53:59 +0000 (19:53 +0100)
commitfae627162d5f8cfb273b10349883eeb74baaa43f
tree87d1760329a310ddc6fd74ab19fd072d3d543133
parenta11052d98db2f2a61841f0c5ee84de4ca1b3e296
coroutines: Only set parm copy guard vars if we have exceptions [PR 102454].

For coroutines, we make copies of the original function arguments into
the coroutine frame.  Normally, these are destroyed on the proper exit
from the coroutine when the frame is destroyed.

However, if an exception is thrown before the first suspend point is
reached, the cleanup has to happen in the ramp function.  These cleanups
are guarded such that they are only applied to any param copies actually
made.

The ICE is caused by an attempt to set the guard variable when there are
no exceptions enabled (the guard var is not created in this case).

Fixed by checking for flag_exceptions in this case too.

While touching this code paths, also clean up the synthetic names used
when a function parm is unnamed.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/102454

gcc/cp/ChangeLog:

* coroutines.cc (analyze_fn_parms): Clean up synthetic names for
unnamed function params.
(morph_fn_to_coro): Do not try to set a guard variable for param
DTORs in the ramp, unless we have exceptions active.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr102454.C: New test.
gcc/cp/coroutines.cc
gcc/testsuite/g++.dg/coroutines/pr102454.C [new file with mode: 0644]