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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-11-10
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The difference is that the CONST_DECL is added only to one RECORD_TYPE and not
to its variants in:
  if (context && context == current_class_type && !SCOPED_ENUM_P (enumtype))
    {
      /* In something like `struct S { enum E { i = 7 }; };' we put `i'
         on the TYPE_FIELDS list for `S'.  (That's so that you can say
         things like `S::i' later.)  */

      /* The enumerator may be getting declared outside of its enclosing
         class, like so:

           class S { public: enum E : int; }; enum S::E : int { i = 7; };

         For which case we need to make sure that the access of `S::i'
         matches the access of `S::E'.  */
      tree saved_cas = current_access_specifier;
      if (TREE_PRIVATE (TYPE_NAME (enumtype)))
        current_access_specifier = access_private_node;
      else if (TREE_PROTECTED (TYPE_NAME (enumtype)))
        current_access_specifier = access_protected_node;
      else
        current_access_specifier = access_public_node;

      finish_member_declaration (decl);

      current_access_specifier = saved_cas;
    }

For dwarf2out purposes the extra CONST_DECL doesn't mean anything, because it
is ignored for non-fortran/ada.  So, either we change the type verifier to
ignore extra CONST_DECLs among TYPE_FIELDS, or if we have some way in the FE
how to figure out if fixup_type_variants has been already called or will be
still called, then we could for the case where it has been called already call
it again or just update TYPE_FIELDS manually on the variant types, or append to
TYPE_FIELDS rather than prepend if the type has been finalized already.

Reply via email to