re PR c++/77637 (ICE on x86_64-linux-gnu (Segmentation fault, tree_check, cp_parser_s...
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Sep 2016 15:16:55 +0000 (17:16 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 20 Sep 2016 15:16:55 +0000 (17:16 +0200)
PR c++/77637
* parser.c (cp_parser_std_attribute_list): Reject ... without
preceding attribute.

* g++.dg/cpp0x/gen-attrs-62.C: New test.

From-SVN: r240265

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/gen-attrs-62.C [new file with mode: 0644]

index 6aa79a9..35ad431 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/77637
+       * parser.c (cp_parser_std_attribute_list): Reject ... without
+       preceding attribute.
+
 2016-09-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        PR c++/77434
index c03b9c2..9a20a5f 100644 (file)
@@ -24221,8 +24221,12 @@ cp_parser_std_attribute_list (cp_parser *parser, tree attr_ns)
       if (token->type == CPP_ELLIPSIS)
        {
          cp_lexer_consume_token (parser->lexer);
-         TREE_VALUE (attribute)
-           = make_pack_expansion (TREE_VALUE (attribute));
+         if (attribute == NULL_TREE)
+           error_at (token->location,
+                     "expected attribute before %<...%>");
+         else
+           TREE_VALUE (attribute)
+             = make_pack_expansion (TREE_VALUE (attribute));
          token = cp_lexer_peek_token (parser->lexer);
        }
       if (token->type != CPP_COMMA)
index d434027..b4524f0 100644 (file)
@@ -1,5 +1,8 @@
 2016-09-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77637
+       * g++.dg/cpp0x/gen-attrs-62.C: New test.
+
        PR middle-end/77624
        * c-c++-common/pr77624-1.c: New test.
        * c-c++-common/pr77624-2.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-62.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-62.C
new file mode 100644 (file)
index 0000000..5bd8778
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/77637
+// { dg-do compile { target c++11 } }
+
+int [[...]] a;         // { dg-error "expected attribute before '...'" }
+int [[,,...]] b;       // { dg-error "expected attribute before '...'" }