From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x431.google.com with SMTP id g12so11137307wrs.10; Sat, 12 Nov 2022 15:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aEk3yolF9di8qqxmRZ5KMHlsJPJsQwZlQ54q0nz4qeY=; b=mPs+XbqPzHyg5022dZKbLTYdLyLuerO2sc+ckIV/lAACnHLW185Fjlmvw5iS2GVQZE hc9ZDmK5bJDqwLIWLFksDNTCA2LMyOB82LZzAOM/44NbaYhvjVSgzQXggRBQFCnctJwO ae1k1QlUaGnReiRrfeP8uL25WTD+ex36SC+82Y6GKZmTbQZRiXyR3j8SDLyFqCr0W8OR oqQF4WYL32hvcJAC38hrrPE9Ba9Sdo8IbQJPQoZVx+cJ2Yt/fJC43bUK1Z+0jNSWFALb UjJsNnP2iWmTOlIKCEcqoKrWNDJRTTSn85cYbG15gK5fwFFoN9pkL1gzmrLpPkYjQfbc 2ULg== 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-Google-Smtp-Source: AA0mqf7bzBzUNSAb35MuKwdQl8/9pezzTNtoelgZYTd7jKNjhgkNzgHw+hm/u18J7j6n9+gppBMWew== 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) From: Bernhard Reutner-Fischer 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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 -- 2.38.1