> Hmm, this _should_ be a no-op.  Can you, before that line, add
> 
>   gcc_assert (TYPE_CANONICAL (t2) != t2
>               && TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t)));
> 
> ?  That is, the incomplete variant should share TYPE_CANONICAL with
> the pointed-to type and be _not_ the canonical leader (otherwise
> all other pointer types are bogus).

It looks like good idea.  I am re-checking with that change that already
found a bug - build_distinct_type_variant actually resets TYPE_CANONICAL
which I have missed earlier. So I am testing

Index: tree.c
===================================================================
--- tree.c      (revision 265807)
+++ tree.c      (working copy)
@@ -5146,6 +5146,9 @@ fld_incomplete_type_of (tree t, struct f
          else
            first = build_reference_type_for_mode (t2, TYPE_MODE (t),
                                                TYPE_REF_CAN_ALIAS_ALL (t));
+         gcc_assert (TYPE_CANONICAL (t2) != t2
+                     && TYPE_CANONICAL (t2) == TYPE_CANONICAL (TREE_TYPE (t)));
+         TYPE_CANONICAL (first) = TYPE_CANONICAL (TYPE_MAIN_VARIANT (t));
          add_tree_to_fld_list (first, fld);
          return fld_type_variant (first, t, fld);
        }
@@ -5169,6 +5172,7 @@ fld_incomplete_type_of (tree t, struct f
          SET_TYPE_MODE (copy, VOIDmode);
          SET_TYPE_ALIGN (copy, BITS_PER_UNIT);
          TYPE_SIZE_UNIT (copy) = NULL;
+         TYPE_CANONICAL (copy) = t;
          if (AGGREGATE_TYPE_P (t))
            {
              TYPE_FIELDS (copy) = NULL;

Honza

Reply via email to