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. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR c/103649 gcc/ChangeLog: * attribs.c (handle_ignored_attributes_option): Create the fake attribute with max_length == -1. gcc/testsuite/ChangeLog: * c-c++-common/Wno-attributes-6.c: New test. --- gcc/attribs.c | 2 +- gcc/testsuite/c-c++-common/Wno-attributes-6.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/Wno-attributes-6.c diff --git a/gcc/attribs.c b/gcc/attribs.c index 29703e75fba..4933f020f1a 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -304,7 +304,7 @@ handle_ignored_attributes_option (vec<char *> *v) We can't free it here, so squirrel away the pointers. */ attribute_spec *table = new attribute_spec[2]; ignored_attributes_table.safe_push (table); - table[0] = { attr, 0, 0, false, false, false, false, nullptr, nullptr }; + table[0] = { attr, 0, -1, false, false, false, false, nullptr, nullptr }; table[1] = { nullptr, 0, 0, false, false, false, false, nullptr, nullptr }; register_scoped_attributes (table, IDENTIFIER_POINTER (vendor_id), !attr); diff --git a/gcc/testsuite/c-c++-common/Wno-attributes-6.c b/gcc/testsuite/c-c++-common/Wno-attributes-6.c new file mode 100644 index 00000000000..02cdaaa1e89 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wno-attributes-6.c @@ -0,0 +1,9 @@ +/* PR c/103649 */ +/* { dg-do compile { target { c || c++11 } } } */ +/* { dg-additional-options "-Wno-attributes=foo::bar" } */ +/* { dg-additional-options "-Wno-attributes=baz::" } */ + +[[foo::bar(1, 2)]]; /* { dg-warning "attribute ignored" } */ +[[baz::bar(1, 2)]]; /* { dg-warning "attribute ignored" } */ +[[foo::bar(1, 2)]] void f1(); +[[baz::bar(1, 2)]] void f2(); base-commit: f91814c22595e1db642140efe030caf2c092ab6f -- 2.33.1