diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2024-08-14 13:30:30 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2024-08-21 09:25:29 +0100 |
commit | 3949b7c0a87475692d1727086bdccb8133c53497 (patch) | |
tree | 53f6ea555fd8056a00f5863590622c32fb39eb61 /gcc | |
parent | cc8fc9850d1a4b614da104cfecd4c2368ee03c98 (diff) | |
download | gcc-3949b7c0a87475692d1727086bdccb8133c53497.zip gcc-3949b7c0a87475692d1727086bdccb8133c53497.tar.gz gcc-3949b7c0a87475692d1727086bdccb8133c53497.tar.bz2 |
c++, coroutines: Check for malformed functions before splitting.
This performs the same basic check that is done by finish_function
to catch cases where the function is so badly malformed that we
do not have a consistent binding level.
gcc/cp/ChangeLog:
* coroutines.cc (split_coroutine_body_from_ramp): Check
that the binding level is as expected before attempting
to outline the function body.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/coroutines.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index f7791cb..7af2a18 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -4553,10 +4553,16 @@ coro_rewrite_function_body (location_t fn_start, tree fnbody, tree orig, static tree split_coroutine_body_from_ramp (tree fndecl) { - tree body; + /* Sanity-check and punt if we have a nonsense tree because of earlier + parse errors, perhaps. */ + if (!current_binding_level + || current_binding_level->kind != sk_function_parms) + return NULL_TREE; + /* Once we've tied off the original user-authored body in fn_body. Start the replacement synthesized ramp body. */ + tree body; if (use_eh_spec_block (fndecl)) { body = pop_stmt_list (TREE_OPERAND (current_eh_spec_block, 0)); |