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: 19270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1471608wru; Sat, 12 Nov 2022 15:48:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf5jw4SHArWZrD3Wir5Q3c9JemduNW/3ub6QztZy0Oonj12uubtemVnn6wLAwAISTcv0mb2s X-Received: by 2002:a17:906:bc42:b0:78d:7a4c:13ea with SMTP id s2-20020a170906bc4200b0078d7a4c13eamr6340365ejv.471.1668296918080; Sat, 12 Nov 2022 15:48:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668296918; cv=none; d=google.com; s=arc-20160816; b=I6mOuO6TqmHJ2uhbyVm93qfFzp2WuImlLqHzgPhSUan2ciXhDRDnr8HynAGvmdNCZ2 silSKbRNUQCGJI+YEQjDI4uN4gQLz9e0mGCVGmnaOEdziD5z1tvvQfXQlLHojIyX0V2Z mqwgqtuqL57CTtNVUkmygU0Oucck602GqzTQsQwifxkY8wpxWyvJ77paHtZvy98an6mh h0Hc+r9IahHUwcZsiA2JKU+plU5Ayhaq5UEp1IZQSXn48sjrGknuFGQ8T9EMAwuPDCA9 ulnmLPHl5Gk64AvdNXRh+XF5ovs0B8aeW3AHzspNSTLpDjHBWRIw13To7Ag4evH/QyGB 9LLA== 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=YEv9FQ1bNUkETM+fNqeiGPFH8ZhUHuhSH9iWVk3yrNU=; b=Z0lMIerVYTpG0D+iX0PzIOddoMNINYWUTeEI1AmKDZcjT10ebozVxXzTEcf3LRWc4R kNleBRdl3oqm0oVkgI+lY8iTBTfm9GwjVt3uzvbN0WLC8oBelpiT8RxpjWDq6zfDHLuO R253kslB5EQgjGqR/VpewU878ODZR7db0Bnkj4FWwZNcgLZ+YMPrYQ914RryVLrCOcTC VDedYXiUOG17k5oLk9YD92/QuSfMt/LCWNhERypdOWWGk9GtWy7qMUbto1Oo24h07rAt Tc0iGIEq8AiKu+zHV1kUZypsbABvtM1otpuwa/YB958mcfNIWQBP72TpzjsT5Mr7xr4K X2YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YVAORRm0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gu7-20020a170906f28700b007adb3888afbsi4302944ejb.136.2022.11.12.15.48.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 15:48:38 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YVAORRm0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 D226738A815E for ; Sat, 12 Nov 2022 23:47:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D226738A815E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668296858; 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=YVAORRm0Qh+QuZU0UX2s/idz/GZvIl7nGADHXQvKeEPXzUWFey8V9QSDbm4HKkDfX 57Ii04GXFhkz42Z6MCn++kzzf/Ibm2vF1zdmEiOtfqllxbbYL/Dp4qoqJGxc8aWowk XCBhBCc0Tul0xtmo4WL2+enMDrE7UUfRSg7OVIu0= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749336109584846086?= X-GMAIL-MSGID: =?utf-8?q?1749336109584846086?= 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;