coroutines: Wrap co_await in a target expr where needed [PR95050]
authorIain Sandoe <iain@sandoe.co.uk>
Tue, 2 Jun 2020 15:47:54 +0000 (16:47 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 2 Jun 2020 18:10:28 +0000 (19:10 +0100)
commit324276ff9b1aa5128e5cb9f5d43182d1ebab0752
treed38572dea31e7d15363b5f645da700f6c6396638
parentce95db102aab4dea9af24a20de78db2f57c0a37b
coroutines: Wrap co_await in a target expr where needed [PR95050]

Since the co_await expression is mostly opaque to the existing
machinery, we were hiding the details of the await_resume return
value.  If that needs to be wrapped in a target expression, then
emulate this with the whole co_await.  Similarly, if the await
expression we build in response to co_await p.yield_value (e)
is wrapped in a target expression, then we need to transfer that
wrapper to the resultant CO_YIELD_EXPR (which is, itself, just
a proxy for the underlying co_await).

gcc/cp/ChangeLog:

PR c++/95050
* coroutines.cc (build_co_await): Wrap the co_await expression
in a TARGET_EXPR, where needed.
(finish_co_yield_expr): Likewise.

gcc/testsuite/ChangeLog:

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