https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87957

--- Comment #30 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
We cannot change the TYPE_DECL setting in Ada, it has been like this for 25
years and is the root of the translation process for entities in gigi:

/* Similar, but GNAT_ENTITY is assumed to refer to a GNAT type.  Return
   the GCC type corresponding to that entity.  */

tree
gnat_to_gnu_type (Entity_Id gnat_entity)
{
  tree gnu_decl;

  /* The back end never attempts to annotate generic types.  */
  if (Is_Generic_Type (gnat_entity) && type_annotate_only)
     return void_type_node;

  gnu_decl = gnat_to_gnu_entity (gnat_entity, NULL_TREE, false);
  gcc_assert (TREE_CODE (gnu_decl) == TYPE_DECL);

  return TREE_TYPE (gnu_decl);
}

So what happens in fld_incomplete_type_of if the TYPE_DECL doesn't point to the
main variant?  The comment reads:

          /* Build copy of TYPE_DECL in TYPE_NAME if necessary.
             This is needed for ODR violation warnings to come out right (we
             want duplicate TYPE_DECLs whenever the type is duplicated because
             of ODR violation.  Because lang data in the TYPE_DECL may not
             have been freed yet, rebuild it from scratch and copy relevant
             fields.  */

There can be no ODR violations for user-defined types in Ada so can we skip it?

Reply via email to