Message ID | 20201217150419.GU3788@tucnak |
---|---|
State | New |
Headers | show |
Series | c++: Fix PCH ICE with __builtin_source_location [PR98343] | expand |
On 12/17/20 10:04 AM, Jakub Jelinek wrote: > Hi! > > Seems the ggc_remove ppc_nx 3 operand member relies on the hash tables to > contain pointers in the first element, which is not the case for > source_location_table* hash table, which has location_t and unsigned as > first two members and pointer somewhere else. > I've tried to change: > static void > pch_nx (T &p, gt_pointer_operator op, void *cookie) > { > - op (&p, cookie); > + extern void gt_pch_nx (T *, gt_pointer_operator, void *); > + gt_pch_nx (&p, op, cookie); > } > in hash-traits.h, but that failed miserably. > So, this patch instead overrides the two pch_nx overloads (only the second > one is needed, the former one is identical to the ggc_remove one) but I need > to override both. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. > 2020-12-17 Jakub Jelinek <jakub@redhat.com> > > PR c++/98343 > * cp-gimplify.c (source_location_table_entry_hash::pch_nx): Override > static member functions from ggc_remove. > > * g++.dg/pch/pr98343.C: New test. > * g++.dg/pch/pr98343.Hs: New file. > > --- gcc/cp/cp-gimplify.c.jj 2020-12-17 12:56:28.787727736 +0100 > +++ gcc/cp/cp-gimplify.c 2020-12-17 13:02:49.675447405 +0100 > @@ -2931,6 +2931,21 @@ struct source_location_table_entry_hash > && ref.uid == 0 > && ref.var == NULL_TREE); > } > + > + static void > + pch_nx (source_location_table_entry &p) > + { > + extern void gt_pch_nx (source_location_table_entry &); > + gt_pch_nx (p); > + } > + > + static void > + pch_nx (source_location_table_entry &p, gt_pointer_operator op, void *cookie) > + { > + extern void gt_pch_nx (source_location_table_entry *, gt_pointer_operator, > + void *); > + gt_pch_nx (&p, op, cookie); > + } > }; > > static GTY(()) hash_table <source_location_table_entry_hash> > --- gcc/testsuite/g++.dg/pch/pr98343.C.jj 2020-12-17 13:12:32.678887902 +0100 > +++ gcc/testsuite/g++.dg/pch/pr98343.C 2020-12-17 13:11:59.962256358 +0100 > @@ -0,0 +1,6 @@ > +// PR c++/98343 > +// { dg-options "-std=c++2a" } > + > +#include "pr98343.H" > + > +const void *ptr2 = __builtin_source_location (); > --- gcc/testsuite/g++.dg/pch/pr98343.Hs.jj 2020-12-17 13:12:36.035850093 +0100 > +++ gcc/testsuite/g++.dg/pch/pr98343.Hs 2020-12-17 13:11:44.918425789 +0100 > @@ -0,0 +1,18 @@ > +// PR c++/98343 > +// { dg-options "-std=c++2a" } > + > +namespace std > +{ > + struct source_location > + { > + struct __impl > + { > + const char* _M_file_name; > + const char* _M_function_name; > + unsigned _M_line; > + unsigned _M_column; > + }; > + const __impl* _M_impl; > + }; > +} > +const void *ptr = __builtin_source_location (); > > Jakub >
--- gcc/cp/cp-gimplify.c.jj 2020-12-17 12:56:28.787727736 +0100 +++ gcc/cp/cp-gimplify.c 2020-12-17 13:02:49.675447405 +0100 @@ -2931,6 +2931,21 @@ struct source_location_table_entry_hash && ref.uid == 0 && ref.var == NULL_TREE); } + + static void + pch_nx (source_location_table_entry &p) + { + extern void gt_pch_nx (source_location_table_entry &); + gt_pch_nx (p); + } + + static void + pch_nx (source_location_table_entry &p, gt_pointer_operator op, void *cookie) + { + extern void gt_pch_nx (source_location_table_entry *, gt_pointer_operator, + void *); + gt_pch_nx (&p, op, cookie); + } }; static GTY(()) hash_table <source_location_table_entry_hash> --- gcc/testsuite/g++.dg/pch/pr98343.C.jj 2020-12-17 13:12:32.678887902 +0100 +++ gcc/testsuite/g++.dg/pch/pr98343.C 2020-12-17 13:11:59.962256358 +0100 @@ -0,0 +1,6 @@ +// PR c++/98343 +// { dg-options "-std=c++2a" } + +#include "pr98343.H" + +const void *ptr2 = __builtin_source_location (); --- gcc/testsuite/g++.dg/pch/pr98343.Hs.jj 2020-12-17 13:12:36.035850093 +0100 +++ gcc/testsuite/g++.dg/pch/pr98343.Hs 2020-12-17 13:11:44.918425789 +0100 @@ -0,0 +1,18 @@ +// PR c++/98343 +// { dg-options "-std=c++2a" } + +namespace std +{ + struct source_location + { + struct __impl + { + const char* _M_file_name; + const char* _M_function_name; + unsigned _M_line; + unsigned _M_column; + }; + const __impl* _M_impl; + }; +} +const void *ptr = __builtin_source_location ();