coroutines: Fix handling of target cleanup exprs [PR94883]
authorIain Sandoe <iain@sandoe.co.uk>
Wed, 29 Apr 2020 18:46:35 +0000 (19:46 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Thu, 30 Apr 2020 14:58:48 +0000 (15:58 +0100)
commitaa94a22f5cb337e173d7119ffd5a92f1e607f544
tree9c9e6e0016044853d6888e89af6d1509fbd017b4
parentb16fd5fd8afe6f95c8ae44e759971e605c31f97b
coroutines: Fix handling of target cleanup exprs [PR94883]

The problem here is that target cleanup expressions have been
added to the initialisers for the awaitable (and returns of
non-trivial values from await_suspend() calls.  This is because
the expansion of the co_await into its control flow is not
apparent to the machinery adding the target cleanup expressions.
The solution being tested is simply to recreate target expressions
as the co_awaits are lowered.  Teaching the machinery to handle
walking co_await expressions in different ways at different points
(outside the coroutine transformation) seems overly complex.

gcc/cp/ChangeLog:

2020-04-30  Iain Sandoe  <iain@sandoe.co.uk>

PR c++/94883
* coroutines.cc (register_awaits): Update target
expressions for awaitable and suspend handle
initializers.

gcc/testsuite/ChangeLog:

2020-04-30  Iain Sandoe  <iain@sandoe.co.uk>

PR c++/94883
* g++.dg/coroutines/pr94883-folly-2.C: New test.
gcc/cp/ChangeLog
gcc/cp/coroutines.cc
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/coroutines/pr94883-folly-2.C [new file with mode: 0644]