From patchwork Sat Nov 12 23:45:39 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: 1703169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=O2JPtcHt; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N8sgT0LSKz1yqS for ; Sun, 13 Nov 2022 10:47:17 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F081E3896C3D for ; Sat, 12 Nov 2022 23:47:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F081E3896C3D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668296835; bh=YEv9FQ1bNUkETM+fNqeiGPFH8ZhUHuhSH9iWVk3yrNU=; 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=O2JPtcHtg2QPB37irjPmk6vI2ljwFeTCScAIT9afdK1VUkdGbHJDbVLmc68zEkKCS nQna+coBdkHnc0mKxTVN9Yqp6Xk3Hh6FyuoBoB73m0BIWitP2ubQjgBLdyGHAO0org c0Fgx4UlWC9nUkgS8SVmLyOfYlWHTibMQvSxLhkI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 355783887F54; Sat, 12 Nov 2022 23:45:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 355783887F54 Received: by mail-wm1-x32e.google.com with SMTP id t25-20020a1c7719000000b003cfa34ea516so7082433wmi.1; 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=YEv9FQ1bNUkETM+fNqeiGPFH8ZhUHuhSH9iWVk3yrNU=; b=7GbXFIm77XiLJv7ZqTCOzeFAs+ob/nEi0NVwjXdldnXXNYBxyLcMwCoTu249nlirAh XN0HmVRPZTHoBB+5OJBmCFTT8uet5Olkgo5i+rT9RqqfBOzpHb9p6+FDjNow4oFMOK98 xHpXdLP+ro88LSmZP+gywj/2iP5DCuaPVOVnbCtp5S0xubfD4wVVd+qgRH7IrO/Wl56d CmAhuq8+oPppYudchaep3jG101WUzrfoBufV5sv6tynBPDbEznoCUGUVSc2GUXR+up5I +xWDPYIfTss80iHAZ0B2iG/blaWCYR2pb5hRLz74TA3KxvnuMolBOlo4EOLNjeqp8Pn7 ZFxg== X-Gm-Message-State: ANoB5pnzxVCb+D5m1tEnm9oN49H8nfnkO0/oLvMdnZ1o/wpD62VrcPwd Eigl0E+pbEZI8rc7N0oyh5s= X-Google-Smtp-Source: AA0mqf61CmLkfchoUQ+zCHchCFmLFWRQLP98PbnFE1qMqauVAjdgu1tw/a8Z6sQga2Mh4E5SkogFKg== X-Received: by 2002:a05:600c:35d6:b0:3cf:cf89:2f02 with SMTP id r22-20020a05600c35d600b003cfcf892f02mr4724920wmq.2.1668296746935; 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 c7-20020a1c3507000000b003c6f1732f65sm12631398wma.38.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-000Opo-02; 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, Joseph Myers Subject: [PATCH 1/5] c: Set the locus of the function result decl Date: Sun, 13 Nov 2022 00:45:39 +0100 Message-Id: <20221112234543.95441-2-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.7 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Bootstrapped and regtested on x86_86-unknown-linux with no regressions. Ok for trunk? Cc: Joseph Myers --- gcc/c/ChangeLog: * c-decl.cc (start_function): Set the result decl source location to the location of the typespec. --- gcc/c/c-decl.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index a99b7456055..5250cb96c41 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -9980,6 +9980,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, tree decl1, old_decl; tree restype, resdecl; location_t loc; + location_t result_loc; current_function_returns_value = 0; /* Assume, until we see it does. */ current_function_returns_null = 0; @@ -10206,8 +10207,11 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, push_scope (); declare_parm_level (); + /* Set the result decl source location to the location of the typespec. */ + result_loc = (declspecs->locations[cdw_typespec] == UNKNOWN_LOCATION + ? loc : declspecs->locations[cdw_typespec]); restype = TREE_TYPE (TREE_TYPE (current_function_decl)); - resdecl = build_decl (loc, RESULT_DECL, NULL_TREE, restype); + resdecl = build_decl (result_loc, RESULT_DECL, NULL_TREE, restype); DECL_ARTIFICIAL (resdecl) = 1; DECL_IGNORED_P (resdecl) = 1; DECL_RESULT (current_function_decl) = resdecl;