public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
@ 2020-07-29 16:50 haoxintu at gmail dot com
  2020-07-30  6:05 ` [Bug c++/96380] " rguenth at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-29 16:50 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96380
           Summary: [10/11 Regression] ICE in tree check: expected
                    integer_cst, have view_convert_expr in get_len, at
                    tree.h:5954
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This invalid code makes GCC-trunk and GCC-10.2 ICE, and GCC-10 downwards
versions compile it well without ICE.

Input:
//small.cc
const int a;
const long b;
enum struct c;
template <class> enum struct c : union enum class c { e = b, f = a }; 
enum class c {};

Command:
g++ -fermissive -w small.cc

Output:
small.cc:5:15: internal compiler error: tree check: expected integer_cst, have
view_convert_expr in get_len, at tree.h:5954
    5 | enum class c {};
      |               ^
0x7eb991 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/tree.c:9687
0x8aeffa tree_check(tree_node const*, char const*, int, char const*, tree_code)
        ../../gcc/tree.h:3559
0x8aeffa wi::extended_tree<192>::get_len() const
        ../../gcc/tree.h:5954
0x8aeffa wi::int_traits<generic_wide_int<wi::extended_tree<192> >
>::decompose(long*, unsigned int, generic_wide_int<wi::extended_tree<192> >
const&)
        ../../gcc/wide-int.h:985
0x8aeffa wide_int_ref_storage<true,
false>::wide_int_ref_storage<generic_wide_int<wi::extended_tree<192> >
>(generic_wide_int<wi::extended_tree<192> > const&, unsigned int)
        ../../gcc/wide-int.h:1034
0x8aeffa generic_wide_int<wide_int_ref_storage<true, false>
>::generic_wide_int<generic_wide_int<wi::extended_tree<192> >
>(generic_wide_int<wi::extended_tree<192> > const&, unsigned int)
        ../../gcc/wide-int.h:790
0x8aeffa bool wi::lts_p<generic_wide_int<wi::extended_tree<192> >,
generic_wide_int<wi::extended_tree<192> >
>(generic_wide_int<wi::extended_tree<192> > const&,
generic_wide_int<wi::extended_tree<192> > const&)
        ../../gcc/wide-int.h:1901
0x93bc08 wi::binary_traits<generic_wide_int<wi::extended_tree<192> >,
generic_wide_int<wi::extended_tree<192> >,
wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::precision_type,
wi::int_traits<generic_wide_int<wi::extended_tree<192> >
>::precision_type>::signed_predicate_result operator<
<generic_wide_int<wi::extended_tree<192> >,
generic_wide_int<wi::extended_tree<192> >
>(generic_wide_int<wi::extended_tree<192> > const&,
generic_wide_int<wi::extended_tree<192> > const&)
        ../../gcc/wide-int.h:3248
0x93bc08 tree_int_cst_lt(tree_node const*, tree_node const*)
        ../../gcc/tree.h:6110
0x93bc08 finish_enum_value_list(tree_node*)
        ../../gcc/cp/decl.c:15573
0x9cc89b cp_parser_enum_specifier
        ../../gcc/cp/parser.c:19483
0x9cc89b cp_parser_type_specifier
        ../../gcc/cp/parser.c:17769
0x9cd17e cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14436
0x9cdf31 cp_parser_simple_declaration
        ../../gcc/cp/parser.c:13690
0x9f929e cp_parser_declaration
        ../../gcc/cp/parser.c:13510
0x9f998b cp_parser_translation_unit
        ../../gcc/cp/parser.c:4793
0x9f998b c_parse_file()
        ../../gcc/cp/parser.c:44081
0xb144fd c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1188
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reproduced in Godbolt : https://godbolt.org/z/YGPxsj

Thanks,
Haoxin

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
@ 2020-07-30  6:05 ` rguenth at gcc dot gnu.org
  2020-07-30  7:41 ` marxin at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-30  6:05 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.2.0
   Target Milestone|---                         |10.3
      Known to work|                            |10.1.0

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
  2020-07-30  6:05 ` [Bug c++/96380] " rguenth at gcc dot gnu.org
@ 2020-07-30  7:41 ` marxin at gcc dot gnu.org
  2020-07-30  7:41 ` marxin at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-07-30  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=96379
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-2064-g4fd124a23664c712.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
  2020-07-30  6:05 ` [Bug c++/96380] " rguenth at gcc dot gnu.org
  2020-07-30  7:41 ` marxin at gcc dot gnu.org
@ 2020-07-30  7:41 ` marxin at gcc dot gnu.org
  2020-07-30 15:10 ` mpolacek at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-07-30  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-07-30

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  2020-07-30  7:41 ` marxin at gcc dot gnu.org
@ 2020-07-30 15:10 ` mpolacek at gcc dot gnu.org
  2020-10-12 12:40 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-30 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (3 preceding siblings ...)
  2020-07-30 15:10 ` mpolacek at gcc dot gnu.org
@ 2020-10-12 12:40 ` rguenth at gcc dot gnu.org
  2021-03-29 16:54 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-12 12:40 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (4 preceding siblings ...)
  2020-10-12 12:40 ` rguenth at gcc dot gnu.org
@ 2021-03-29 16:54 ` jakub at gcc dot gnu.org
  2021-03-29 17:04 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-29 16:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
           Keywords|                            |accepts-invalid

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
extern const int a, b;
enum struct c;
template <class>
enum struct c : union enum struct c { e = b, f = a }; 
enum class c {};

ICEs even without -fpermissive.

And
extern const int a, b;
enum struct c;
template <class>
enum struct c : union enum struct c { e = b, f = a }; 
is accepted for some reason, even when for e.g.
template <class>
enum E : int { F };
we reject it:
error: template declaration of ‘enum E’

Marek, have you made any progress on this?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (5 preceding siblings ...)
  2021-03-29 16:54 ` jakub at gcc dot gnu.org
@ 2021-03-29 17:04 ` mpolacek at gcc dot gnu.org
  2021-04-08 12:02 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-29 17:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> extern const int a, b;
> enum struct c;
> template <class>
> enum struct c : union enum struct c { e = b, f = a }; 
> enum class c {};
> 
> ICEs even without -fpermissive.
> 
> And
> extern const int a, b;
> enum struct c;
> template <class>
> enum struct c : union enum struct c { e = b, f = a }; 
> is accepted for some reason, even when for e.g.
> template <class>
> enum E : int { F };
> we reject it:
> error: template declaration of ‘enum E’
> 
> Marek, have you made any progress on this?

Not yet, sorry.  Hopefully this week then.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (6 preceding siblings ...)
  2021-03-29 17:04 ` mpolacek at gcc dot gnu.org
@ 2021-04-08 12:02 ` rguenth at gcc dot gnu.org
  2021-04-20 16:17 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-08 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.3                        |10.4

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10.3 is being released, retargeting bugs to GCC 10.4.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (7 preceding siblings ...)
  2021-04-08 12:02 ` rguenth at gcc dot gnu.org
@ 2021-04-20 16:17 ` mpolacek at gcc dot gnu.org
  2021-04-20 19:38 ` [Bug c++/96380] [10/11/12 " mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-20 16:17 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression] ICE   |[10/11 Regression] ICE in
                   |in tree check: expected     |tree check: expected
                   |integer_cst, have           |integer_cst, have
                   |view_convert_expr in        |view_convert_expr in
                   |get_len, at tree.h:5954     |get_len, at tree.h:5954

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #3)
> (In reply to Jakub Jelinek from comment #2)
> > Marek, have you made any progress on this?
> 
> Not yet, sorry.  Hopefully this week then.

Testing a patch now.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11/12 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (8 preceding siblings ...)
  2021-04-20 16:17 ` mpolacek at gcc dot gnu.org
@ 2021-04-20 19:38 ` mpolacek at gcc dot gnu.org
  2021-04-21 15:12 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-20 19:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
*** Bug 96379 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11/12 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (9 preceding siblings ...)
  2021-04-20 19:38 ` [Bug c++/96380] [10/11/12 " mpolacek at gcc dot gnu.org
@ 2021-04-21 15:12 ` cvs-commit at gcc dot gnu.org
  2021-04-21 15:14 ` [Bug c++/96380] [10/11 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-21 15:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:001c63d15e31bc0a1545426d889a0b9f671b4961

commit r12-42-g001c63d15e31bc0a1545426d889a0b9f671b4961
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Apr 20 12:16:04 2021 -0400

    c++: Don't allow defining types in enum-base [PR96380]

    In r11-2064 I made cp_parser_enum_specifier commit to tentative parse
    when seeing a '{'.  That still looks like the correct thing to do, but
    it caused an ICE-on-invalid as well as accepts-invalid.

    When we have something sneaky like this, which is broken in multiple
    ways:

      template <class>
      enum struct c : union enum struct c { e = b, f = a };

    we parse the "enum struct c" part (that's OK) and then we see that
    we have an enum-base, so we consume ':' and then parse the type-specifier
    that follows the :.  "union enum" is clearly invalid, but we're still
    parsing tentatively and we parse everything up to the ;, and then
    throw away the underlying type.  We parsed everything because we were
    tricked into parsing an enum-specifier in an enum-base of another
    enum-specifier!  Not good.

    Since the grammar for enum-base doesn't allow a defining-type-specifier,
    only a type-specifier, we should set type_definition_forbidden_message
    which fixes all the problems in this PR.

    gcc/cp/ChangeLog:

            PR c++/96380
            * parser.c (cp_parser_enum_specifier): Don't allow defining
            types in enum-base.

    gcc/testsuite/ChangeLog:

            PR c++/96380
            * g++.dg/cpp0x/enum_base4.C: New test.
            * g++.dg/cpp0x/enum_base5.C: New test.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (10 preceding siblings ...)
  2021-04-21 15:12 ` cvs-commit at gcc dot gnu.org
@ 2021-04-21 15:14 ` mpolacek at gcc dot gnu.org
  2021-04-27 16:41 ` cvs-commit at gcc dot gnu.org
  2021-12-02 13:29 ` [Bug c++/96380] [10 " mpolacek at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-21 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression] ICE   |[10/11 Regression] ICE in
                   |in tree check: expected     |tree check: expected
                   |integer_cst, have           |integer_cst, have
                   |view_convert_expr in        |view_convert_expr in
                   |get_len, at tree.h:5954     |get_len, at tree.h:5954

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk (GCC 12) so far.  Will backport to 11.2 and 10.4.  Note: The
patch uses auto, needs tweaking before backporting to 10.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (11 preceding siblings ...)
  2021-04-21 15:14 ` [Bug c++/96380] [10/11 " mpolacek at gcc dot gnu.org
@ 2021-04-27 16:41 ` cvs-commit at gcc dot gnu.org
  2021-12-02 13:29 ` [Bug c++/96380] [10 " mpolacek at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-27 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:af53e450e5c61e36bd01aa2db1251483a60be007

commit r11-8305-gaf53e450e5c61e36bd01aa2db1251483a60be007
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Apr 20 12:16:04 2021 -0400

    c++: Don't allow defining types in enum-base [PR96380]

    In r11-2064 I made cp_parser_enum_specifier commit to tentative parse
    when seeing a '{'.  That still looks like the correct thing to do, but
    it caused an ICE-on-invalid as well as accepts-invalid.

    When we have something sneaky like this, which is broken in multiple
    ways:

      template <class>
      enum struct c : union enum struct c { e = b, f = a };

    we parse the "enum struct c" part (that's OK) and then we see that
    we have an enum-base, so we consume ':' and then parse the type-specifier
    that follows the :.  "union enum" is clearly invalid, but we're still
    parsing tentatively and we parse everything up to the ;, and then
    throw away the underlying type.  We parsed everything because we were
    tricked into parsing an enum-specifier in an enum-base of another
    enum-specifier!  Not good.

    Since the grammar for enum-base doesn't allow a defining-type-specifier,
    only a type-specifier, we should set type_definition_forbidden_message
    which fixes all the problems in this PR.

    gcc/cp/ChangeLog:

            PR c++/96380
            * parser.c (cp_parser_enum_specifier): Don't allow defining
            types in enum-base.

    gcc/testsuite/ChangeLog:

            PR c++/96380
            * g++.dg/cpp0x/enum_base4.C: New test.
            * g++.dg/cpp0x/enum_base5.C: New test.

    (cherry picked from commit 001c63d15e31bc0a1545426d889a0b9f671b4961)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/96380] [10 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954
  2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
                   ` (12 preceding siblings ...)
  2021-04-27 16:41 ` cvs-commit at gcc dot gnu.org
@ 2021-12-02 13:29 ` mpolacek at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-02 13:29 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-12-02 13:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 16:50 [Bug c++/96380] New: [10/11 Regression] ICE in tree check: expected integer_cst, have view_convert_expr in get_len, at tree.h:5954 haoxintu at gmail dot com
2020-07-30  6:05 ` [Bug c++/96380] " rguenth at gcc dot gnu.org
2020-07-30  7:41 ` marxin at gcc dot gnu.org
2020-07-30  7:41 ` marxin at gcc dot gnu.org
2020-07-30 15:10 ` mpolacek at gcc dot gnu.org
2020-10-12 12:40 ` rguenth at gcc dot gnu.org
2021-03-29 16:54 ` jakub at gcc dot gnu.org
2021-03-29 17:04 ` mpolacek at gcc dot gnu.org
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2021-04-20 16:17 ` mpolacek at gcc dot gnu.org
2021-04-20 19:38 ` [Bug c++/96380] [10/11/12 " mpolacek at gcc dot gnu.org
2021-04-21 15:12 ` cvs-commit at gcc dot gnu.org
2021-04-21 15:14 ` [Bug c++/96380] [10/11 " mpolacek at gcc dot gnu.org
2021-04-27 16:41 ` cvs-commit at gcc dot gnu.org
2021-12-02 13:29 ` [Bug c++/96380] [10 " mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).