From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id AF79C385843A; Sun, 30 Apr 2023 08:27:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF79C385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682843270; bh=Wr6seMXjVNg3SMUNTvWsb/U1NzuS2+SMpy/YibF7Tps=; h=From:To:Subject:Date:From; b=f88eoA7Io3WAnTPKW/FIq0X/sSzjdndar4b9p+r4EwJsnmuP6yCiHq1Ex19IVvZa5 zH55Er41WIW9QRdEECDD2Sj43MM4JsAskW6irMQBuRDLxNhoU9DqsYx83muPGgSw4/ LlWe9EZ80VaVRQbPlDmlV+7wD5HjDSxBGC+1/3Zw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9502] c++, coroutines: Fix block nests when the function has no top-level bind. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: b7e75cdb218f25708b8b1aa3f4b138d88187491f X-Git-Newrev: 66e43c2387402f1fd48c71fe10275fa8f4c427d5 Message-Id: <20230430082750.AF79C385843A@sourceware.org> Date: Sun, 30 Apr 2023 08:27:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:66e43c2387402f1fd48c71fe10275fa8f4c427d5 commit r12-9502-g66e43c2387402f1fd48c71fe10275fa8f4c427d5 Author: Iain Sandoe Date: Sat Apr 1 21:53:51 2023 +0530 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 gcc/cp/ChangeLog: * coroutines.cc (coro_rewrite_function_body): Ensure that added bind expressions have scope blocks. (cherry picked from commit a8d7631d333c22e38a067d32d11fd2b60cf1d960) Diff: --- gcc/cp/coroutines.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 03ba3f6aa26..85a760d8220 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -4109,6 +4109,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; }