summaryrefslogtreecommitdiff
path: root/gcc/attribs.h
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2021-12-16 16:29:41 -0500
committerMarek Polacek <polacek@redhat.com>2021-12-17 17:56:26 -0500
commit6afb8a68a9113897ccf39e40983e042ed90d7aed (patch)
treedd26347d03e98714dcb291f7a409dde9c04d02e9 /gcc/attribs.h
parent00ea158fa0d44d6d81f5e8a8d875c917bd086b99 (diff)
downloadgcc-6afb8a68a9113897ccf39e40983e042ed90d7aed.tar.gz
attribs: Fix wrong error with -Wno-attribute=A::b [PR103649]
My patch to implement -Wno-attribute=A::b caused a bogus error when parsing [[foo::bar(1, 2)]]; when -Wno-attributes=foo::bar was specified on the command line, because when we create a fake foo::bar attribute and insert it into our attribute table, it is created with max_length == 0 which doesn't allow any args. That is wrong -- we know nothing about the attribute, so we shouldn't require any specific number of arguments. And since unknown attributes can be rather complex (see for example omp::{directive,sequence}), we must skip parsing their arguments. To that end, I'm using max_length with value -2. Also let's not warn about things like [[vendor::assume(true)]]; because they may have some meaning (this is reminiscent of C++ Portable Assumptions). PR c/103649 gcc/ChangeLog: * attribs.c (handle_ignored_attributes_option): Create the fake attribute with max_length == -2. (attribute_ignored_p): New overloads. * attribs.h (attribute_ignored_p): Declare them. * tree-core.h (struct attribute_spec): Document that max_length can be -2. gcc/c/ChangeLog: * c-decl.c (c_warn_unused_attributes): Don't warn for attribute_ignored_p. * c-parser.c (c_parser_std_attribute): Skip parsing of the attribute arguments when the attribute is ignored. gcc/cp/ChangeLog: * parser.c (cp_parser_declaration): Don't warn for attribute_ignored_p. (cp_parser_std_attribute): Skip parsing of the attribute arguments when the attribute is ignored. gcc/testsuite/ChangeLog: * c-c++-common/Wno-attributes-6.c: New test.
Diffstat (limited to 'gcc/attribs.h')
-rw-r--r--gcc/attribs.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/attribs.h b/gcc/attribs.h
index f5899d83c0b..4928b126f59 100644
--- a/gcc/attribs.h
+++ b/gcc/attribs.h
@@ -39,6 +39,8 @@ extern tree get_attribute_name (const_tree);
extern tree get_attribute_namespace (const_tree);
extern void apply_tm_attr (tree, tree);
extern tree make_attribute (const char *, const char *, tree);
+extern bool attribute_ignored_p (tree);
+extern bool attribute_ignored_p (const attribute_spec *const);
extern struct scoped_attributes* register_scoped_attributes (const struct attribute_spec *,
const char *,