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.129.124]) by sourceware.org (Postfix) with ESMTPS id 6588E3947C27 for ; Tue, 15 Nov 2022 23:52:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6588E3947C27 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=1668556369; 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=pzJoaAHYfpe7Vtcp+Qa3yoiVaRNr4pEFZSZeGRrPxbM=; b=Logmy1avLKatkFsT0CmV2VkxjxknhO2Qfe8W+J291V/u+0XR5ZSRomXEp6gUZEy/0HlvR9 2lWj/cGc7Wlu5wxs3YMHA3Y8FlEla1LOtp2ZYW7n7JV+eJ3rnF/uB+7eBLWBKo1EHcNgF0 oRS4fo2H5ypHfDWB+bRje6pfEcN73HE= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-513-zK84A751Pxun2wmd8IBJ_g-1; Tue, 15 Nov 2022 18:52:47 -0500 X-MC-Unique: zK84A751Pxun2wmd8IBJ_g-1 Received: by mail-qv1-f69.google.com with SMTP id h1-20020a0ceda1000000b004b899df67a4so11871858qvr.1 for ; Tue, 15 Nov 2022 15:52:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=k9lxcwFdq0BTetJH3dYSWL+1ZZEZvegpLGeai3N+63M=; b=q7pFEzd0KAOj/PmYGiksVQe1tiXfvDE9y+l7GO9cNVYAj1709p4UbafPrfJJ0dcJWV L/y6hDop2BIFSgMMAGEjJu8wlCkEiPPxnrM4GLF7xuLSwPNyZpQ27PmGnv3R1nkuVd2l kj3gOvEjmedtbuWEdTMD+rHPQzaq9hXPehdgRzyjuy/m1XUQQ+H97sMQQER30PiF4L4m MY4tGELNOds1VMsNMz5HTG6HRuJx2GwwCOm71qJvVTrUZjtxu75BbgSaPE82y77DZLmt 2Cow3VFre3Q4UDGZ2l/NqHE9tffdqu/HweVLepenmQROUFEXrY0mDf9fCba20LfHSwYE FzMg== X-Gm-Message-State: ANoB5plYGYq40C914E98e1l3BfPlpbRzX77qsDBZcu1i4SZXcnrRjGYJ RZPczZOVVFS9YPIhzEpzUB8yCylY0wIpy50JFV/2s9kBMyz4EYxeSIeK+eKPfdbIuYyOT/w/+xV Yly/xpNrHfC69MFygxQ== X-Received: by 2002:a05:622a:1f92:b0:3a5:8517:c3f3 with SMTP id cb18-20020a05622a1f9200b003a58517c3f3mr18741479qtb.618.1668556367460; Tue, 15 Nov 2022 15:52:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nNWpSZSvJbNV85InD6+FzJ1sb6ZAX5nhr69AxYzLyyUzkpLy+2iunILNezO2Nx044KLrPXA== X-Received: by 2002:a05:622a:1f92:b0:3a5:8517:c3f3 with SMTP id cb18-20020a05622a1f9200b003a58517c3f3mr18741466qtb.618.1668556367186; Tue, 15 Nov 2022 15:52:47 -0800 (PST) Received: from [192.168.1.101] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id dm56-20020a05620a1d7800b006eeb51bb33dsm8963594qkb.78.2022.11.15.15.52.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Nov 2022 15:52:44 -0800 (PST) Message-ID: Date: Tue, 15 Nov 2022 18:52:41 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH 2/5] c++: Set the locus of the function result decl To: Bernhard Reutner-Fischer , gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer , fortran@gcc.gnu.org, Nathan Sidwell References: <20221112234543.95441-1-aldot@gcc.gnu.org> <20221112234543.95441-3-aldot@gcc.gnu.org> From: Jason Merrill In-Reply-To: <20221112234543.95441-3-aldot@gcc.gnu.org> 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=-16.0 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,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 11/12/22 13:45, Bernhard Reutner-Fischer wrote: > gcc/cp/ChangeLog: > > * decl.cc (start_function): Set the result decl source location to > the location of the typespec. > > --- > Bootstrapped and regtested on x86_86-unknown-linux with no regressions. > Ok for trunk? > > Cc: Nathan Sidwell > Cc: Jason Merrill > --- > gcc/cp/decl.cc | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc > index 6e98ea35a39..ed40815e645 100644 > --- a/gcc/cp/decl.cc > +++ b/gcc/cp/decl.cc > @@ -17449,6 +17449,8 @@ start_function (cp_decl_specifier_seq *declspecs, > tree attrs) > { > tree decl1; > + tree result; > + bool ret; We now prefer to declare new variables as late as possible, usually when they are initialized. > decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs); > invoke_plugin_callbacks (PLUGIN_START_PARSE_FUNCTION, decl1); > @@ -17461,7 +17463,18 @@ start_function (cp_decl_specifier_seq *declspecs, > gcc_assert (same_type_p (TREE_TYPE (TREE_TYPE (decl1)), > integer_type_node)); > > - return start_preparsed_function (decl1, attrs, /*flags=*/SF_DEFAULT); > + ret = start_preparsed_function (decl1, attrs, /*flags=*/SF_DEFAULT); > + > + /* decl1 might be ggc_freed here. */ > + decl1 = current_function_decl; > + > + /* Set the result decl source location to the location of the typespec. */ > + if (TREE_CODE (decl1) == FUNCTION_DECL > + && declspecs->locations[ds_type_spec] != UNKNOWN_LOCATION > + && (result = DECL_RESULT (decl1)) != NULL_TREE > + && DECL_SOURCE_LOCATION (result) == input_location) > + DECL_SOURCE_LOCATION (result) = declspecs->locations[ds_type_spec]; One way to handle the template case would be for the code in start_preparsed_function that sets DECL_RESULT to check whether decl1 is a template instantiation, and in that case copy the location from the template's DECL_RESULT, i.e. DECL_RESULT (DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (decl1))) > + return ret; > } > > /* Returns true iff an EH_SPEC_BLOCK should be created in the body of