[C/C++ PATCH] Fix ICE with typedef redeclaration with attributes (PR c/89933)

Jason Merrill jason@redhat.com
Fri Apr 12 19:56:00 GMT 2019


On 4/12/19 3:19 AM, Jakub Jelinek wrote:
> In r234626 Marek has added code to remove TREE_TYPE (newdecl) from
> its variant list for typedefs, because we'll ggc_free the TYPE_NAME of that
> type.  Unfortunately, that code will ICE if TREE_TYPE (newdecl) is its own
> TYPE_MAIN_VARIANT.  This can happen if due to attributes the newdecl's type
> has been build_distinct_type_copy created but hasn't been type_hash_canon
> merged (which we do for a few attributes like aligned, but certainly don't
> do it for most other attributes).  In the likely case there are no variants
> for that type yet, there is just nothing to remove.  If there are some (in
> theory), the options are do what the following patch does, keep the type
> in the variant list as the main variant, just change the TYPE_NAME, so that
> it doesn't refer to ggc_freed TYPE_DECL, or try to pick up some other type
> as the main variant and adjust the whole variant list (I don't think the
> C/C++ FEs unlike Ada FE like e.g. qualified types as main variant though).

If the typedef is a duplicate, the type ought to be garbage as well, no?

Jason



More information about the Gcc-patches mailing list