[C++ PATCH] Fix ICE with scoped enums and -g (PR c++/72808)

Jason Merrill jason@redhat.com
Mon Nov 28 17:26:00 GMT 2016


OK.

On Mon, Nov 28, 2016 at 10:38 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Nov 28, 2016 at 09:44:30AM -0500, Jason Merrill wrote:
>> On Fri, Nov 25, 2016 at 12:31 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> >         * decl.c (build_enumerator): Call fixup_type_variants on
>> >         current_class_type after finish_member_declaration.
>>
>> Let's do this in finish_enum_value_list, in the block controlled by
>>
>>   if (at_class_scope_p ()
>>       && COMPLETE_TYPE_P (current_class_type)
>>       && UNSCOPED_ENUM_P (enumtype))
>
> Following fixes the ICE, will bootstrap/regtest it now.
>
> 2016-11-28  Jakub Jelinek  <jakub@redhat.com>
>             Jason Merrill  <jason@redhat.com>
>
>         PR c++/72808
>         * decl.c (finish_enum_value_list): Call fixup_type_variants on
>         current_class_type after
>         insert_late_enum_def_into_classtype_sorted_fields.
>
>         * g++.dg/debug/pr72808.C: New test.
>
> --- gcc/cp/decl.c.jj    2016-11-28 16:28:40.000000000 +0100
> +++ gcc/cp/decl.c       2016-11-28 16:35:29.636721634 +0100
> @@ -14280,8 +14280,11 @@ finish_enum_value_list (tree enumtype)
>    if (at_class_scope_p ()
>        && COMPLETE_TYPE_P (current_class_type)
>        && UNSCOPED_ENUM_P (enumtype))
> -    insert_late_enum_def_into_classtype_sorted_fields (enumtype,
> -                                                      current_class_type);
> +    {
> +      insert_late_enum_def_into_classtype_sorted_fields (enumtype,
> +                                                        current_class_type);
> +      fixup_type_variants (current_class_type);
> +    }
>
>    /* Finish debugging output for this type.  */
>    rest_of_type_compilation (enumtype, namespace_bindings_p ());
> --- gcc/testsuite/g++.dg/debug/pr72808.C.jj     2016-11-28 16:28:32.581153120 +0100
> +++ gcc/testsuite/g++.dg/debug/pr72808.C        2016-11-28 16:28:32.581153120 +0100
> @@ -0,0 +1,24 @@
> +// PR c++/72808
> +// { dg-do compile }
> +// { dg-options "-g -std=c++14" }
> +
> +struct A
> +{
> +  virtual void foo ();
> +};
> +
> +struct B : A
> +{
> +  void foo ();
> +  enum C : int;
> +};
> +
> +enum B::C : int
> +{
> +  D
> +};
> +
> +void
> +B::foo ()
> +{
> +}
>
>         Jakub



More information about the Gcc-patches mailing list