https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101582
Bug ID: 101582 Summary: C++ FE doesn't accept attribute-declaration Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- [[]]; is rejected by gcc (accepted by clang) in C++11 and later mode: error: declaration does not declare anything [-fpermissive] It is fine to warn about attributes we don't handle and throw away, like we e.g. on empty statements with attributes warn attributes at the beginning of statement are ignored [-Wattributes] except for the few like [[fallthrough]] or [[cold]], but we shouldn't reject it with permerror. I'll need it for OpenMP directives in attributes... Implementation-wise, I think one option is in cp_parser_toplevel_declaration after the else if (token->type == CPP_SEMICOLON) { cp_lexer_consume_token (parser->lexer); /* A declaration consisting of a single semicolon is invalid * before C++11. Allow it unless we're being pedantic. */ if (cxx_dialect < cxx11) pedwarn (input_location, OPT_Wpedantic, "extra %<;%>"); } case try cp_parser_skip_std_attribute_spec_seq and if the token after it is CPP_SEMICOLON, handle it as attribute-declaration, or faster but less clean grammar-wise in cp_parser_simple_declaration detect the case where we have only std attributes followed by semicolon and handle it there.