public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: C++: missing result_decl loc of (member) functions
Date: Mon, 25 Apr 2022 11:22:17 -0400	[thread overview]
Message-ID: <6a43fe4d-15ae-2c0e-0ea0-de7e909cf9d5@redhat.com> (raw)
In-Reply-To: <20220424160912.5c1f1ba9@nbbrfq>

On 4/24/22 10:09, Bernhard Reutner-Fischer wrote:
> On Wed, 20 Apr 2022 19:20:24 +0200
> Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> 
>> Hi!
>>
>> I'm having a hard time to set the correct location of the result decl of
>> member functions in C++. Any hint on where to best fix the missing
>> locus?
>> TIA for any hint (or a fix :).
>>
>> Long version:
> 
>> ¹) C functions work out fine once fixed to have the correct loc.
>>     C++ functions worked fine once, but i now see that apparently
>>     "int my_main" on line 42 regressed again in the meantime:
> 
> This is due to decl1 having been ggc_freed here:

We might move building the RESULT_DECL from start_preparsed_function to 
grokfndecl, at which point we can set the location directly.  Maybe only 
build it if funcdef_flag is true.

> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
> index c136dbbba1a..38874bf1558 100644
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -17373,7 +17375,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;
> +
> 
> which is why i previously had to use current_function_decl here.
>>
>>
>> $ XXX=1 ../gcc/xg++ -B../gcc -c -o return-narrow.o return-narrow.cc -fdiagnostics-color=always
> 
>> return-narrow.cc: In function ‘int my_main(int, char**)’:
>> return-narrow.cc:42:25: warning: result decl locus sample
>>     42 | int my_main (int, char**) { return 0; }
>>        |                         ^
>>        |                         the return type
> 


      reply	other threads:[~2022-04-25 15:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 17:20 Bernhard Reutner-Fischer
2022-04-24 14:09 ` Bernhard Reutner-Fischer
2022-04-25 15:22   ` Jason Merrill [this message]

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=6a43fe4d-15ae-2c0e-0ea0-de7e909cf9d5@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=rep.dot.nop@gmail.com \
    /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).