From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 35E6C3858D1E for ; Sat, 8 Apr 2023 17:10:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35E6C3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680973831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iJc8e49caqILOKMQBYzH80eLigr8BRxxSR4KlJX/Xhc=; b=VV5XqLSLVQYx01gIv3ky0fRI1eMbpcPulwI3c+l5VA3VM0aU5DrMSaw0aFNFnTlm27s1WO zQSoWKQ3JtzFMo1DH+m/Qi21Dn1+qYsDNafF6Ivg4IvxNTNZDDaHIqHxc0RzQe7RzT/Ih0 S08b8Sr9chA/i/gUpHrsvDCbaCPgFsk= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-omHi7YLyM5a0N_DhuEOF1g-1; Sat, 08 Apr 2023 13:10:30 -0400 X-MC-Unique: omHi7YLyM5a0N_DhuEOF1g-1 Received: by mail-pg1-f198.google.com with SMTP id u184-20020a6385c1000000b005039e28b68cso535755pgd.13 for ; Sat, 08 Apr 2023 10:10:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680973829; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iJc8e49caqILOKMQBYzH80eLigr8BRxxSR4KlJX/Xhc=; b=HDPfpXTJBN7OCkLO4apuCUkOsYLes2KR7VKUJvsrCkahnNUKWQLO/X1T9igaf+8j4i EqNitAGaU2Af9Y8I1RySldCs8TaSRi5sk54KqIH+JygKT4uShvMudlzMHH5W18vFitFn gLMHQnK8zFY45dJlOedregyR1c7qjLn3mPQXtdYjLSPQgkluiVcpQL/b/qEux+TWc2fP b6MmPj9hj3nKRdYAVBBFKDNorS3ovCFubRZigC1Rn8i75p7//jRsL4vHMPltkOWE+hzI 7hw/ADMqgwk/FrwEVtsYFLbz33J7fAJXvmh7/lJ8y4NSdOfIU6kNJqZBnogatQ45A35H +y6A== X-Gm-Message-State: AAQBX9eGATRGB2Mg9kzpmUzWIYZxxS5KybiZXbMmH8LaaZ4L9zHAG9Yw iWkTE2SjoOKd9GpUxvT9PWlxUS3xvEk0aV9gO4YOh6uwVcPKoY01eY4XLHFBoCUYARlO13MBG/O 8AvOwP/RjYzjdrBEejA== X-Received: by 2002:a05:6a20:2d9e:b0:e3:9d4e:b340 with SMTP id bf30-20020a056a202d9e00b000e39d4eb340mr4998601pzb.12.1680973829543; Sat, 08 Apr 2023 10:10:29 -0700 (PDT) X-Google-Smtp-Source: AKy350acnLShg/PfwpKPRH0OWwM6V2W/3HAaO0+TCej4UjPRjgAfy63lBweAovFRqCPlCG7eGI1gcQ== X-Received: by 2002:a05:6a20:2d9e:b0:e3:9d4e:b340 with SMTP id bf30-20020a056a202d9e00b000e39d4eb340mr4998589pzb.12.1680973829146; Sat, 08 Apr 2023 10:10:29 -0700 (PDT) Received: from [10.5.204.138] ([136.179.21.71]) by smtp.gmail.com with ESMTPSA id a28-20020a630b5c000000b004e28be19d1csm4094243pgl.32.2023.04.08.10.10.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 Apr 2023 10:10:27 -0700 (PDT) Message-ID: <3377ff7c-3778-c29c-c5a3-19903507f975@redhat.com> Date: Sat, 8 Apr 2023 10:10:25 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] c++, coroutines: Fix block nests when the function has no top-level bind. To: iain@sandoe.co.uk, gcc-patches@gcc.gnu.org Cc: arsen@aarsen.me References: <20230406062737.79723-1-iain@sandoe.co.uk> From: Jason Merrill In-Reply-To: <20230406062737.79723-1-iain@sandoe.co.uk> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 4/6/23 02:27, Iain Sandoe wrote: > I spotted this problem while trying to collate my WIP patches (sorry > for not spotting it when the original patch was discussed). > > Although we do not yet have any regression filed against this (AFAIK), > it's only a matter of time - so I'd suggest that we should apply to > 13. > > Tested on x86_64-darwin21 and x86_64_linux-gnu. > OK for trunk? (when?) > Iain > > --- 8< --- > > 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. > --- > gcc/cp/coroutines.cc | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc > index b307c8ca8b6..59a240ebd40 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; > } I wonder if you want to use c_build_bind_expr for various BIND_EXPR creation? You'll still need to explicitly build a BLOCK in this particular case, as in poplevel with nonzero functionbody, but that might reduce the boilerplate in general. The patch is OK. Jason