diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-08-16 11:43:18 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2024-08-16 11:43:18 +0200 |
commit | 2f90f3850eaf9d703d9eb63d5f0347158aa11027 (patch) | |
tree | e83cc01718e451c4481a55a4d37d0dd551313837 /gcc/go/go-gcc-diagnostics.cc | |
parent | 0470c8e007dfba46aed30ee82c9b0ee79c3d826d (diff) | |
download | gcc-2f90f3850eaf9d703d9eb63d5f0347158aa11027.zip gcc-2f90f3850eaf9d703d9eb63d5f0347158aa11027.tar.gz gcc-2f90f3850eaf9d703d9eb63d5f0347158aa11027.tar.bz2 |
c++: Pedwarn on [[]]; at class scope [PR110345]
For C++ 26 P2552R3 I went through all the spots (except modules) where
attribute-specifier-seq appears in the grammar and tried to construct
a testcase in all those spots, for now for [[deprecated]] attribute.
The fourth issue is that we just emit (when enabled) -Wextra-semi warning
not just for lone semicolon at class scope (correct), but also for
[[]]; or [[whatever]]; there too.
While just semicolon is valid in C++11 and newer,
https://eel.is/c++draft/class.mem#nt:member-declaration
allows empty-declaration, unlike namespace scope or block scope
something like attribute-declaration or empty statement with attributes
applied for it aren't supported.
While syntactically it matches
attribute-specifier-seq [opt] decl-specifier-seq [opt] member-declarator-list [opt] ;
with the latter two omitted, there is
https://eel.is/c++draft/class.mem#general-3
which says that is not valid.
So, the following patch emits a pedwarn in that case.
2024-08-16 Jakub Jelinek <jakub@redhat.com>
PR c++/110345
* parser.cc (cp_parser_member_declaration): Call maybe_warn_extra_semi
only if it is empty-declaration, if there are some tokens like
attribute, pedwarn that the declaration doesn't declare anything.
* g++.dg/cpp0x/gen-attrs-84.C: New test.
Diffstat (limited to 'gcc/go/go-gcc-diagnostics.cc')
0 files changed, 0 insertions, 0 deletions