public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101582] New: C++ FE doesn't accept attribute-declaration
@ 2021-07-22 15:29 jakub at gcc dot gnu.org
  2021-07-22 17:32 ` [Bug c++/101582] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-07-22 15:29 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2021-12-07 19:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 15:29 [Bug c++/101582] New: C++ FE doesn't accept attribute-declaration jakub at gcc dot gnu.org
2021-07-22 17:32 ` [Bug c++/101582] " jakub at gcc dot gnu.org
2021-07-22 21:28 ` pinskia at gcc dot gnu.org
2021-07-30  8:34 ` cvs-commit at gcc dot gnu.org
2021-07-30  8:34 ` jakub at gcc dot gnu.org
2021-12-07 19:38 ` pinskia 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).