diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-12-09 10:20:05 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-12-09 10:20:05 +0100 |
commit | 388ab03975c5c6b3c434ebb95c56c07ea8932486 (patch) | |
tree | 901288c35d4c0f9eef39f4cc3c0cbd1739a6b2d8 /gcc/gcc.cc | |
parent | 9363d91956931bb28735bed97035b9ec965c850f (diff) | |
download | gcc-388ab03975c5c6b3c434ebb95c56c07ea8932486.zip gcc-388ab03975c5c6b3c434ebb95c56c07ea8932486.tar.gz gcc-388ab03975c5c6b3c434ebb95c56c07ea8932486.tar.bz2 |
c++: Don't diagnose ignoring of attributes if all ignored attributes are attribute_ignored_p
There is another thing I wonder about: with -Wno-attributes= we are
supposed to ignore the attributes altogether, but we are actually still
warning about them when we emit these generic warnings about ignoring
all attributes which appertain to this and that (perhaps with some
exceptions we first remove from the attribute chain), like:
void foo () { [[foo::bar]]; }
with -Wattributes -Wno-attributes=foo::bar
Shouldn't we call some helper function in cases like this and warn
not when std_attrs (or how the attribute chain var is called) is non-NULL,
but if it is non-NULL and contains at least one non-attribute_ignored_p
attribute?
I've kept warnings for cases where the C++ standard says explicitly any
attributes aren't ok -
"If an attribute-specifier-seq appertains to a friend declaration, that
declaration shall be a definition."
or
https://eel.is/c++draft/dcl.type.elab#3
or
https://eel.is/c++draft/temp.spec#temp.explicit-3
For some changes I haven't figured out how could I cover it in the
testsuite.
Note, C uses a different strategy, it has c_warn_unused_attributes
function which warns about all the attributes one by one unless they
are ignored (or allowed in certain position).
Though that is just a single diagnostic wording, while C++ FE just warns
that there are some ignored attributes and doesn't name them individually
(except for namespace and using namespace) and uses different wordings in
different spots.
2023-12-09 Jakub Jelinek <jakub@redhat.com>
gcc/
* attribs.h (any_nonignored_attribute_p): Declare.
* attribs.cc (any_nonignored_attribute_p): New function.
gcc/cp/
* parser.cc (cp_parser_statement, cp_parser_expression_statement,
cp_parser_declaration, cp_parser_asm_definition): Don't diagnose
ignored attributes if !any_nonignored_attribute_p.
* decl.cc (grokdeclarator): Likewise.
* name-lookup.cc (handle_namespace_attrs, finish_using_directive):
Don't diagnose ignoring of attr_ignored_p attributes.
gcc/testsuite/
* g++.dg/warn/Wno-attributes-1.C: New test.
Diffstat (limited to 'gcc/gcc.cc')
0 files changed, 0 insertions, 0 deletions