https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95124
Bug ID: 95124 Summary: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in diag_attr_exclusions, at attribs.c:396 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: anbu1024.me at gmail dot com Target Milestone: --- $ cat reduced.c int foo () { x; void bar ( ) { struct struct_0 * var_5 = ( { int x __attribute__ ( ( unused , section ( ".text" ) ) ) ; } ) } } $ gcc-10 --version gcc (GCC) 10.0.1 20200419 (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-10 reduced.c reduced.c: In function ‘foo’: reduced.c:3:2: error: ‘x’ undeclared (first use in this function) 3 | x; | ^ reduced.c:3:2: note: each undeclared identifier is reported only once for each function it appears in reduced.c: In function ‘bar’: reduced.c:7:10: internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in diag_attr_exclusions, at attribs.c:396 7 | struct struct_0 * var_5 = ( { int x __attribute__ ( ( unused , section ( ".text" ) ) ) ; } ) | ^~~~~~~~ 0x731f2f tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../gcc-10-20200419/gcc/tree.c:9777 0x5eaf44 tree_class_check(tree_node*, tree_code_class, char const*, int, char const*) ../../gcc-10-20200419/gcc/tree.h:3410 0x5eaf44 diag_attr_exclusions ../../gcc-10-20200419/gcc/attribs.c:396 0x7d4fda diag_attr_exclusions ../../gcc-10-20200419/gcc/attribs.c:379 0x7d6fb5 decl_attributes(tree_node**, tree_node*, int, tree_node*) ../../gcc-10-20200419/gcc/attribs.c:694 0x7f2554 start_decl(c_declarator*, c_declspecs*, bool, tree_node*) ../../gcc-10-20200419/gcc/c/c-decl.c:5117 0x84cdd5 c_parser_declaration_or_fndef ../../gcc-10-20200419/gcc/c/c-parser.c:2271 0x8302bf c_parser_compound_statement_nostart ../../gcc-10-20200419/gcc/c/c-parser.c:5718 0x831f6f c_parser_postfix_expression ../../gcc-10-20200419/gcc/c/c-parser.c:9113 0x834ada c_parser_unary_expression ../../gcc-10-20200419/gcc/c/c-parser.c:8273 0x83632d c_parser_cast_expression ../../gcc-10-20200419/gcc/c/c-parser.c:8115 0x8365b9 c_parser_binary_expression ../../gcc-10-20200419/gcc/c/c-parser.c:7918 0x837595 c_parser_conditional_expression ../../gcc-10-20200419/gcc/c/c-parser.c:7652 0x837bb0 c_parser_expr_no_commas ../../gcc-10-20200419/gcc/c/c-parser.c:7569 0x83aa4c c_parser_initializer ../../gcc-10-20200419/gcc/c/c-parser.c:5227 0x83aa4c c_parser_initializer ../../gcc-10-20200419/gcc/c/c-parser.c:5219 0x84d193 c_parser_declaration_or_fndef ../../gcc-10-20200419/gcc/c/c-parser.c:2248 0x8302bf c_parser_compound_statement_nostart ../../gcc-10-20200419/gcc/c/c-parser.c:5718 0x84c8c4 c_parser_compound_statement ../../gcc-10-20200419/gcc/c/c-parser.c:5617 0x84e381 c_parser_declaration_or_fndef ../../gcc-10-20200419/gcc/c/c-parser.c:2505 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-9 --version gcc (GCC) 9.3.1 20200425 Copyright (C) 2019 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-9 reduced.c reduced.c: In function ‘foo’: reduced.c:3:2: error: ‘x’ undeclared (first use in this function) 3 | x; | ^ reduced.c:3:2: note: each undeclared identifier is reported only once for each function it appears in reduced.c: In function ‘bar’: reduced.c:7:37: error: section attribute cannot be specified for local variables 7 | struct struct_0 * var_5 = ( { int x __attribute__ ( ( unused , section ( ".text" ) ) ) ; } ) | ^ reduced.c:7:29: error: void value not ignored as it ought to be 7 | struct struct_0 * var_5 = ( { int x __attribute__ ( ( unused , section ( ".text" ) ) ) ; } ) | ^ reduced.c:8:2: error: expected ‘,’ or ‘;’ before ‘}’ token 8 | } | ^ reduced.c: In function ‘foo’: reduced.c:9:1: error: expected declaration or statement at end of input 9 | } | ^ -------------------------------------------------------------------------------- $ gcc-8 --version gcc (GCC) 8.4.1 20200424 Copyright (C) 2018 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-8 reduced.c reduced.c: In function ‘foo’: reduced.c:3:2: error: ‘x’ undeclared (first use in this function) x; ^ reduced.c:3:2: note: each undeclared identifier is reported only once for each function it appears in reduced.c: In function ‘bar’: reduced.c:7:37: error: section attribute cannot be specified for local variables struct struct_0 * var_5 = ( { int x __attribute__ ( ( unused , section ( ".text" ) ) ) ; } ) ^ reduced.c:7:29: error: void value not ignored as it ought to be struct struct_0 * var_5 = ( { int x __attribute__ ( ( unused , section ( ".text" ) ) ) ; } ) ^ reduced.c:8:2: error: expected ‘,’ or ‘;’ before ‘}’ token } ^ reduced.c: In function ‘foo’: reduced.c:9:1: error: expected declaration or statement at end of input } ^