re PR c++/87175 (__attribute__)) is ignored by the parser)
authorJakub Jelinek <jakub@redhat.com>
Fri, 1 Feb 2019 08:42:01 +0000 (09:42 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 1 Feb 2019 08:42:01 +0000 (09:42 +0100)
PR c++/87175
* parser.c (cp_parser_gnu_attributes_opt): Set ok to false
if require_open failed.

* g++.dg/ext/attrib57.C: New test.

From-SVN: r268443

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/attrib57.C [new file with mode: 0644]

index 2a2aba3ad44bd5d049d097a950fbe7e2170035d6..ca3618ee0601afbe0bc0c07c2a81fe7039e0a18a 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/87175
+       * parser.c (cp_parser_gnu_attributes_opt): Set ok to false
+       if require_open failed.
+
 2019-01-31  Marek Polacek  <polacek@redhat.com>
 
        PR c++/89083, c++/80864 - ICE with list initialization in template.
index 16f2a32bc0bffc0946bd60d9f624c6bea242565f..91c5ff42fadb2aa8c0acd3da2f5964339f0b3a9c 100644 (file)
@@ -25768,9 +25768,11 @@ cp_parser_gnu_attributes_opt (cp_parser* parser)
       cp_lexer_consume_token (parser->lexer);
       /* Look for the two `(' tokens.  */
       matching_parens outer_parens;
-      outer_parens.require_open (parser);
+      if (!outer_parens.require_open (parser))
+       ok = false;
       matching_parens inner_parens;
-      inner_parens.require_open (parser);
+      if (!inner_parens.require_open (parser))
+       ok = false;
 
       /* Peek at the next token.  */
       token = cp_lexer_peek_token (parser->lexer);
index 2bf2433529c7351119365d85039dfa3257a45906..520ee15d764a336243dbf382fdb24c34518ebdb3 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/87175
+       * g++.dg/ext/attrib57.C: New test.
+
 2018-02-01  Bin Cheng  <bin.cheng@linux.alibaba.com>
 
        PR tree-optimization/88932
diff --git a/gcc/testsuite/g++.dg/ext/attrib57.C b/gcc/testsuite/g++.dg/ext/attrib57.C
new file mode 100644 (file)
index 0000000..7631f12
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/87175
+// { dg-do compile }
+// { dg-options "" }
+
+struct __attribute__)) foo { };        // { dg-error "expected" }
+struct __attribute__()) bar { };// { dg-error "expected" }