From patchwork Sat Nov 12 23:45:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 19268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1471263wru; Sat, 12 Nov 2022 15:47:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ws/K3RF0HJ1Xa9SCfc73EO4uuyjFKWyQ4IBHiVAGtnLesMMZYH6CgNPEPzQK2J+/nB8qZ X-Received: by 2002:a17:907:1b89:b0:7ad:b51d:39d0 with SMTP id mz9-20020a1709071b8900b007adb51d39d0mr6145680ejc.571.1668296840234; Sat, 12 Nov 2022 15:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668296840; cv=none; d=google.com; s=arc-20160816; b=WjvcE0wJIr2t2vcYeSmMbXawMY1DpTzsKsw2cRFbwV/tw91KFjkk2JM01iNv15MFIj 21L8XFopbdoMZXpSaxvVavgjBZxCsX1svYrv5jxh9Vq8qGXwLUlNNvel+nKDHgyw5PJO Urly9WfwSMU9/RQmpLsUZ6M/JD4IBwx+6jSqfGGDLlJ+T7up6az2JYkT/MPtHyYwYNTz HWbEFif6usHjBSJxXwnXmFHusLP1LrrVBUGKHUGFArATBCpgopponHTcqnYndPoqa94A nTN0z8KKtqA6ElhZLBjVD0jgNKAMCZiDyMJRh7Jf+EJzDo7HTBVw/UTjM+mJ+RN6uUqg IiQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=aEk3yolF9di8qqxmRZ5KMHlsJPJsQwZlQ54q0nz4qeY=; b=lkELfBukPubrp/NYVYW/wIWjIOfQ+AvQE7VpOpbgPNzpOe6WK/+UiZU6tNl1rbq3u2 h95hQaCaF9/OHLmqTOrbSpyyZ7rKkQy+vFYBaw0j4yxRNHiBJ76OnGyfkzFocxEe03xC /2nzMD9y+oaP236Ffz1y1l0+QTYSY8QFRDeAGIe9RJ9T998Tw6JQBQ5zThHVuli4v03O uJ1vhlrVgkCR1CE3AtF9YajBYzxmmwUF/xVPEuru+xDp2OkuCenKCfrSw2LhHE/PihRf MEwYQqT4QQRul8LH1u7+2JefNiX+Omt1UBADPwJFBgvuBUdOBoqSAJ2NB633dRehvxOa TTyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nlmmWPEF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n4-20020aa7c444000000b004618343b140si5492555edr.199.2022.11.12.15.47.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 15:47:20 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nlmmWPEF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AFF373889E1C for ; Sat, 12 Nov 2022 23:46:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFF373889E1C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668296799; bh=aEk3yolF9di8qqxmRZ5KMHlsJPJsQwZlQ54q0nz4qeY=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=nlmmWPEFbzHHJgcWQOszkaUs2ogqE3mCK9zZpMAp4qGQ8B+xWifr8E8JSsBTaILXZ uuoyfZ1JuborIQ/yCVgeBRmCa2cHPVG88ONEoINVc6d5n8zijJiHtLXmF57bMm9PTs W2TR1IZbiA5/Qj7L274MNw9CTSdbw5P9Dsytm1uo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 33FC83858C50; Sat, 12 Nov 2022 23:45:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33FC83858C50 Received: by mail-wr1-x431.google.com with SMTP id g12so11137307wrs.10; Sat, 12 Nov 2022 15:45:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aEk3yolF9di8qqxmRZ5KMHlsJPJsQwZlQ54q0nz4qeY=; b=J13gm5GDtOQBn+nMME/6hV6yisz9em+LOQ7KVPArxy7tQvzOUKskmxXrLhkdvrJ3bH i0PeFfRowYuwfHIEUWZgFmzIBSe0KoBr58kOjj/tSVKAIi08HgybWbhIvHvnPvYPLTPe k4UXE2pE66wZWsMZzSYkigN/n5fU+9gDmGxE67BG2tgbnZ6hDDQVQH+U5s4VY0WcYaZk JGooHwb7bOBl2Inc7sWcMPxjxCiznFQfXT2/WiMNtE8lkqFu0PDvAi1CmdKFqxlkrunM gVV8TUvaiTHm3OhYP2JSM2NNvilZwedUn40QwURsMgG7cUgOoeu3QbT8rJ6yIbXaMGT7 Fojg== X-Gm-Message-State: ANoB5pl+ObOP/6Okxf6kc6VJ1YXjnbkEn2dj7Bzif3dSJk19WHe07Y4L TI6DsnbCXYWgUROWHiglmOQ= X-Received: by 2002:a5d:6086:0:b0:22e:71db:47ba with SMTP id w6-20020a5d6086000000b0022e71db47bamr4415944wrt.359.1668296746649; Sat, 12 Nov 2022 15:45:46 -0800 (PST) Received: from nbbrfq ([2001:871:227:81c4:d7ff:3a0e:48da:5fe3]) by smtp.gmail.com with ESMTPSA id m3-20020a5d6243000000b0023660f6cecfsm5505947wrv.80.2022.11.12.15.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 15:45:45 -0800 (PST) X-Google-Original-From: Bernhard Reutner-Fischer Received: from b by nbbrfq with local (Exim 4.96) (envelope-from ) id 1ou0C1-000Opr-06; Sun, 13 Nov 2022 00:45:45 +0100 To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer , Bernhard Reutner-Fischer , fortran@gcc.gnu.org, Nathan Sidwell , Jason Merrill Subject: [PATCH 2/5] c++: Set the locus of the function result decl Date: Sun, 13 Nov 2022 00:45:40 +0100 Message-Id: <20221112234543.95441-3-aldot@gcc.gnu.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221112234543.95441-1-aldot@gcc.gnu.org> References: <20221112234543.95441-1-aldot@gcc.gnu.org> MIME-Version: 1.0 X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749336027714301791?= X-GMAIL-MSGID: =?utf-8?q?1749336027714301791?= 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; 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]; + return ret; } /* Returns true iff an EH_SPEC_BLOCK should be created in the body of