aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2023-04-01 21:53:51 +0530
committerIain Sandoe <iain@sandoe.co.uk>2023-04-09 07:45:04 +0530
commita8d7631d333c22e38a067d32d11fd2b60cf1d960 (patch)
tree3a9f30bbd5505e226cc219815c92bf0638c47e3d /gcc
parent0f04ebb49468bc99b58e8726b6ddcff47086d562 (diff)
downloadgcc-a8d7631d333c22e38a067d32d11fd2b60cf1d960.zip
gcc-a8d7631d333c22e38a067d32d11fd2b60cf1d960.tar.gz
gcc-a8d7631d333c22e38a067d32d11fd2b60cf1d960.tar.bz2
c++, coroutines: Fix block nests when the function has no top-level bind.
When the function contains no local vars and also no nested scopes, there is no top-level bind expression. Because the rewritten coroutine body will require both local vars and contain nested scopes, we add a bind expression to such functions. When this was done the necessary scope blocks were omitted which leads to disconnected function content. Fixed by adding a new block to the added bind expression. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/cp/ChangeLog: * coroutines.cc (coro_rewrite_function_body): Ensure that added bind expressions have scope blocks.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/coroutines.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index b307c8c..59a240e 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -4113,6 +4113,10 @@ coro_rewrite_function_body (location_t fn_start, tree fnbody, tree orig,
tree bind_wrap = build3_loc (fn_start, BIND_EXPR, void_type_node,
NULL, NULL, NULL);
BIND_EXPR_BODY (bind_wrap) = fnbody;
+ /* Ensure we have a block to connect up the scopes. */
+ tree new_blk = make_node (BLOCK);
+ BIND_EXPR_BLOCK (bind_wrap) = new_blk;
+ BLOCK_SUBBLOCKS (top_block) = new_blk;
fnbody = bind_wrap;
}