coroutines: Revise await expansions [PR94528]
The expansions for await expressions were specific to particular cases, this revises it to be more generic. a: Revise co_await statement walkers. We want to process the co_awaits one statement at a time. We also want to be able to determine the insertion points for new bind scopes needed to cater for temporaries that are captured by reference and have lifetimes that need extension to the end of the full expression. Likewise, the handling of captured references in the evaluation of conditions might result in the need to make a frame copy. This reorganises the statement walking code to make it easier to extend for these purposes. b: Factor reference-captured temp code. We want to be able to use the code that writes a new bind expr with vars (and their initializers) from several places, so split that out of the maybe_promote_captured_temps() function into a new replace_statement_captures (). Update some comments. c: Generalize await statement expansion. This revises the expansion to avoid the need to expand conditionally on the tree type. It resolves PR 94528. gcc/cp/ChangeLog: 2020-04-10 Iain Sandoe <iain@sandoe.co.uk> PR c++/94538 * coroutines.cc (co_await_expander): Remove. (expand_one_await_expression): New. (process_one_statement): New. (await_statement_expander): New. (build_actor_fn): Revise to use per-statement expander. (struct susp_frame_data): Reorder and comment. (register_awaits): Factor code. (replace_statement_captures): New, factored from... (maybe_promote_captured_temps):.. here. (await_statement_walker): Revise to process per statement. (morph_fn_to_coro): Use revised susp_frame_data layout. gcc/testsuite/ChangeLog: 2020-04-10 Iain Sandoe <iain@sandoe.co.uk> PR c++/94538 * g++.dg/coroutines/pr94528.C: New test.
Showing
This diff is collapsed.
Click to expand it.
gcc/testsuite/g++.dg/coroutines/pr94528.C
0 → 100644
Please
register
or
sign in
to comment