aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-11-26 22:58:22 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-11-26 22:58:22 +0100
commit4e4a8c28f3da0264eb76dff0efe21b4b5ce63b84 (patch)
tree64fc447a5a41dcfbfa6d66fa56da2a919eee8283 /gcc
parent05d6cb1a858151016dbd368fd8b0792f73423d19 (diff)
downloadgcc-4e4a8c28f3da0264eb76dff0efe21b4b5ce63b84.zip
gcc-4e4a8c28f3da0264eb76dff0efe21b4b5ce63b84.tar.gz
gcc-4e4a8c28f3da0264eb76dff0efe21b4b5ce63b84.tar.bz2
re PR c++/92648 (Handling of unknown attributes)
PR c++/92648 * parser.c (cp_parser_std_attribute): For unknown attributes, skip balanced token seq instead of trying to parse attribute-argument-clause as expression list. Formatting fix. * g++.dg/cpp0x/gen-attrs-71.C: New test. From-SVN: r278737
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/parser.c11
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/gen-attrs-71.C7
4 files changed, 25 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index be36daa..a7c0bca 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2019-11-26 Jakub Jelinek <jakub@redhat.com>
+ PR c++/92648
+ * parser.c (cp_parser_std_attribute): For unknown attributes,
+ skip balanced token seq instead of trying to parse
+ attribute-argument-clause as expression list. Formatting fix.
+
PR c++/61414
* class.c (enum_to_min_precision): New hash_map.
(enum_min_precision): New function.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index be31286..d0c9ff0 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -26629,6 +26629,15 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns)
/* A GNU attribute that takes an identifier in parameter. */
attr_flag = id_attr;
+ if (as == NULL)
+ {
+ /* For unknown attributes, just skip balanced tokens instead of
+ trying to parse the arguments. */
+ for (size_t n = cp_parser_skip_balanced_tokens (parser, 1) - 1; n; --n)
+ cp_lexer_consume_token (parser->lexer);
+ return attribute;
+ }
+
vec = cp_parser_parenthesized_expression_list
(parser, attr_flag, /*cast_p=*/false,
/*allow_expansion_p=*/true,
@@ -26637,7 +26646,7 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns)
arguments = error_mark_node;
else
{
- if (vec->is_empty())
+ if (vec->is_empty ())
/* e.g. [[attr()]]. */
error_at (token->location, "parentheses must be omitted if "
"%qE attribute argument list is empty",
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6a77732..32ba76b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2019-11-26 Jakub Jelinek <jakub@redhat.com>
+ PR c++/92648
+ * g++.dg/cpp0x/gen-attrs-71.C: New test.
+
PR c++/61414
* g++.dg/cpp0x/enum23.C: Remove xfail.
* g++.dg/cpp0x/enum28.C: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-71.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-71.C
new file mode 100644
index 0000000..7876a2f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-71.C
@@ -0,0 +1,7 @@
+// PR c++/92648
+// { dg-do compile { target c++11 } }
+
+int a [[gnu::no_such_attribute(![!(!)!]!,;;)]]; // { dg-warning "ignored" }
+int b [[no_such_namespace::nonexisting_attribute(linear(c, d : 2), reduction(*:e), linear(uval (f)))]]; // { dg-warning "ignored" }
+int c [[gnu::nonexisting_attribute()]]; // { dg-warning "ignored" }
+int d [[gnu::another_nonexistent_attr(1,"abcd",g+6)]]; // { dg-warning "ignored" }