Re: C++: missing result_decl loc of (member) functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux