[PATCH] add -Wmismatched-tags (PR 61339)

Jakub Jelinek jakub@redhat.com
Thu Dec 5 23:47:00 GMT 2019


On Thu, Dec 05, 2019 at 04:33:10PM -0700, Martin Sebor wrote:
> > It's hard to distinguish between this type and the previous one by name;
> > this one should probably have "map" in its name.
> > 
> > > +static GTY (()) record_to_locs_t *rec2loc;
> > ...
> > > +    rec2loc = new record_to_locs_t ();
> > 
> > If this isn't GC-allocated, marking it with GTY(()) seems wrong.  How do
> > you imagine this warning interacting with PCH?
> 
> I have to confess I know too little about PCH to have an idea how
> it might interact.  Is there something you suggest I try testing?

For your patch, obviously some struct/class forward declarations or
definitions in a header that you compile into PCH and then the main testcase
that contains the mismatched pairs.

If there is something that you need to record during parsing of the
precompiled header and use later on, everything needs to be GGC allocated.
So, the hash_map needs to be created with something like
hash_map<something, something_else>::create_ggc (nnn)
and it really can't use pointer hashing, but has to use some different one
(say on DECL_UID, TYPE_UID etc.), because the addresses are remapped during
PCH save/restore cycle, but hash tables aren't rehashed.
See e.g. PR92458.

	Jakub



More information about the Gcc-patches mailing list