]> git.ipfire.org Git - thirdparty/gcc.git/commit
coroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133].
authorIain Sandoe <iain@sandoe.co.uk>
Sat, 2 Oct 2021 12:40:09 +0000 (13:40 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Sun, 3 Oct 2021 19:46:03 +0000 (20:46 +0100)
commit1b54a7226368bf86361e5c9d8ae523193037a0ac
tree804878fd3d978136f250c3b55a4fbc62d30345f6
parent0ee1ab15c237ffb50be1a5ce9c5e542b16df4d12
coroutines: Ensure co_await_exprs have TREE_SIDE_EFFECTS set [PR 101133].

Although it is not immediately evident from the symptoms, the PR is
caused by a variable having a DECL_INITIAL() containing a co_await.
This is not correct, since such expressions have side-effects.

We were marking the overall co_await expression correctly, but if a
consumer of that expression stripped out the underlying co_await_expr
then the latter would not be properly marked.

Fixed by marking both the underlying and any containing await expr
with TREE_SIDE_EFFECTS.  Also mark type-dependent co_await expressions.

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

gcc/cp/ChangeLog:

* coroutines.cc (build_co_await): Mark co_await_expr trees
with TREE_SIDE_EFFECTS, also mark any containing expression.
(finish_co_await_expr): Mark type-dependent co_await_expr
trees with TREE_SIDE_EFFECTS.

gcc/testsuite/ChangeLog:

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