public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-4134] c: Set the locus of the function result decl
Date: Thu, 17 Nov 2022 19:41:32 +0000 (GMT)	[thread overview]
Message-ID: <20221117194132.F3AB43852C72@sourceware.org> (raw)

https://gcc.gnu.org/g:3f467ea953431aa6af12aaed6d32f476f7ace1e5

commit r13-4134-g3f467ea953431aa6af12aaed6d32f476f7ace1e5
Author: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Date:   Sat Nov 6 06:48:00 2021 +0100

    c: Set the locus of the function result decl
    
    gcc/c/ChangeLog:
    
            * c-decl.cc (start_function): Set the result decl source
            location to the location of the typespec.

Diff:
---
 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 36de77814ba..098e475f65d 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -10059,6 +10059,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;
@@ -10285,8 +10286,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;

                 reply	other threads:[~2022-11-17 19:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221117194132.F3AB43852C72@sourceware.org \
    --to=aldot@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).