Hi
while working on path to replace type variant by first compatible one I run
into issue that the first vairant was not seen by free_lang_data. I think this
is a bug becuase nothing prevents middle-end from looking up a variant there
and using it when it needs to do so.

I tried to walk the variant lists and free lang data on them but that crahses
because not all types in variant list passes verify_type (C++ puts there
incomplete type variants whose canonical type is complete and thus they are
considered bogus). So pruning those lists seems to be better variant.

Bootstrapped/regtested x86_64-linux, OK?

Honza

        * tree.c (free_lang_data_in_cgraph): Prune TYPE_NEXT_VARIANT lists.
Index: tree.c
===================================================================
--- tree.c      (revision 263989)
+++ tree.c      (working copy)
@@ -5845,7 +5845,12 @@ free_lang_data_in_cgraph (void)
 
   /* Traverse every type found freeing its language data.  */
   FOR_EACH_VEC_ELT (fld.types, i, t)
-    free_lang_data_in_type (t);
+    {
+      free_lang_data_in_type (t);
+      while (TYPE_NEXT_VARIANT (t)
+            && !fld.pset.contains (TYPE_NEXT_VARIANT (t)))
+       TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (TYPE_NEXT_VARIANT (t));
+    }
   if (flag_checking)
     {
       FOR_EACH_VEC_ELT (fld.types, i, t)

Reply via email to