$ cat test-6951.c static inline void sub_1 ( ) { struct struct_1 var_9 , var_10 } static int var_9[1] __attribute__ ( ( section ( ".data" ) ) ) ; -------------------------------------------------------------------------------- $ gcc-11 --version gcc (GCC) 11.0.0 20201129 (experimental) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -------------------------------------------------------------------------------- $ gcc-11 test-6951.c test-6951.c: In function ‘sub_1’: test-6951.c:3:25: error: storage size of ‘var_9’ isn’t known 3 | struct struct_1 var_9 , var_10 | ^~~~~ test-6951.c:4:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘}’ token 4 | } | ^ test-6951.c:6:1: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in decl_or_type_attrs, at c-family/c-attribs.c:775 6 | static int var_9[1] __attribute__ ( ( section ( ".data" ) ) ) ; | ^~~~~~ 0x753c11 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../gcc-11-20201129/gcc/tree.c:9860 0x642f30 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../gcc-11-20201129/gcc/tree.h:3454 0x642f30 decl_or_type_attrs ../../gcc-11-20201129/gcc/c-family/c-attribs.c:775 0x642f30 validate_attr_args ../../gcc-11-20201129/gcc/c-family/c-attribs.c:803 0x90691d validate_attr_arg ../../gcc-11-20201129/gcc/c-family/c-attribs.c:889 0x90691d handle_section_attribute ../../gcc-11-20201129/gcc/c-family/c-attribs.c:2132 0x80d0dc decl_attributes(tree_node**, tree_node*, int, tree_node*) ../../gcc-11-20201129/gcc/attribs.c:723 0x8295f2 start_decl(c_declarator*, c_declspecs*, bool, tree_node*, unsigned int*) ../../gcc-11-20201129/gcc/c/c-decl.c:5188 0x884e32 c_parser_declaration_or_fndef ../../gcc-11-20201129/gcc/c/c-parser.c:2302 0x867ef0 c_parser_compound_statement_nostart ../../gcc-11-20201129/gcc/c/c-parser.c:5700 0x8848f5 c_parser_compound_statement ../../gcc-11-20201129/gcc/c/c-parser.c:5597 0x886378 c_parser_declaration_or_fndef ../../gcc-11-20201129/gcc/c/c-parser.c:2539 0x88dbe3 c_parser_external_declaration ../../gcc-11-20201129/gcc/c/c-parser.c:1777 0x88e629 c_parser_translation_unit ../../gcc-11-20201129/gcc/c/c-parser.c:1650 0x88e629 c_parse_file() ../../gcc-11-20201129/gcc/c/c-parser.c:21877 0x8ebdfd c_common_parse_file() ../../gcc-11-20201129/gcc/c-family/c-opts.c:1198 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. -------------------------------------------------------------------------------- $ gcc-10 --version gcc (GCC) 10.2.1 20201128 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -------------------------------------------------------------------------------- $ gcc-10 test-6951.c test-6951.c: In function ‘sub_1’: test-6951.c:3:18: error: storage size of ‘var_9’ isn’t known 3 | struct struct_1 var_9 , var_10 | ^~~~~ test-6951.c:4:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘}’ token 4 | } | ^ test-6951.c:6:1: error: expected declaration or statement at end of input 6 | static int var_9[1] __attribute__ ( ( section ( ".data" ) ) ) ; | ^~~~~~
Started with r10-2526-gf0033821c1c9ba38.
Can you check with gcc trunk? There were recent fixes in the handling of noinit/persistent attribute: g:762ca20364a590be2cb9c79c0101ccbff74b5de1
The current master is still affected.
This simple patch avoids the ICE: diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 1d2ab7c..8847932 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -767,6 +767,10 @@ decl_or_type_attrs (tree node) return attrs; tree type = TREE_TYPE (node); + + if (type == error_mark_node) + return NULL_TREE; + return TYPE_ATTRIBUTES (type); }
GCC 11.1 has been released, retargeting bugs to GCC 11.2.
GCC 11.2 is being released, retargeting bugs to GCC 11.3
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>: https://gcc.gnu.org/g:4565a07a646949e6ce30a08c60484afe1fed0ac1 commit r12-7681-g4565a07a646949e6ce30a08c60484afe1fed0ac1 Author: Roger Sayle <roger@nextmovesoftware.com> Date: Wed Mar 16 23:20:34 2022 +0000 PR c/98198: ICE-on-invalid-code error recovery. This is Christophe Lyon's fix to PR c/98198, an ICE-on-invalid-code regression affecting mainline, and a suitable testcase. Tested on x86_64-pc-linux-gnu with make bootstrap and make -k check with no new failures. Ok for mainline? 2022-03-16 Christophe Lyon <christophe.lyon@arm.com> Roger Sayle <roger@nextmovesoftware.com> gcc/c-family/ChangeLog PR c/98198 * c-attribs.cc (decl_or_type_attrs): Add error_mark_node check. gcc/testsuite/ChangeLog PR c/98198 * gcc.dg/pr98198.c: New test case.
This has now been fixed on mainline.