https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96637
Bug ID: 96637
Summary: ICE in tree check: expected tree_list, have error_mark
in cp_check_const_attributes, at cp/decl2.c:1423
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: error-recovery, 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: ---
Input:
//small.cc
void foo(int[] alignas[1] alignas(1)){}
Command:
g++ small.cc
Output:
small.cc:1:23: error: expected ‘(’ before ‘[’ token
1 | void foo(int[] alignas[1] alignas(1)){}
| ^
| (
small.cc:1:36: internal compiler error: tree check: expected tree_list, have
error_mark in cp_check_const_attributes, at cp/decl2.c:1423
1 | void foo(int[] alignas[1] alignas(1)){}
| ^
0x7e9339 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../../gcc/tree.c:9714
0x649182 tree_check(tree_node*, char const*, int, char const*, tree_code)
../../gcc/tree.h:3295
0x649182 cp_check_const_attributes(tree_node*)
../../gcc/cp/decl2.c:1423
0x955b72 cp_check_const_attributes(tree_node*)
../../gcc/cp/decl2.c:1416
0x955b72 cplus_decl_attributes(tree_node**, tree_node*, int)
../../gcc/cp/decl2.c:1584
0x9f27a4 cp_parser_parameter_declaration_list
../../gcc/cp/parser.c:22725
0x9f2b21 cp_parser_parameter_declaration_clause
../../gcc/cp/parser.c:22622
0x9df4f1 cp_parser_direct_declarator
../../gcc/cp/parser.c:21299
0x9df4f1 cp_parser_declarator
../../gcc/cp/parser.c:21163
0x9f4756 cp_parser_init_declarator
../../gcc/cp/parser.c:20663
0x9d4f7c cp_parser_simple_declaration
../../gcc/cp/parser.c:13811
0xa002fe cp_parser_declaration
../../gcc/cp/parser.c:13510
0xa009db cp_parser_translation_unit
../../gcc/cp/parser.c:4793
0xa009db c_parse_file()
../../gcc/cp/parser.c:44095
0xb1b9fd 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.
I tested this in trunk, and this also makes released GCC "confused by earlier
errors, bailing out".