PR c++/84936 - ICE with unexpanded pack in mem-initializer.
authorJason Merrill <jason@redhat.com>
Thu, 5 Apr 2018 00:09:05 +0000 (20:09 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 5 Apr 2018 00:09:05 +0000 (20:09 -0400)
* parser.c (cp_parser_mem_initializer_list): Call
check_for_bare_parameter_packs.

From-SVN: r259107

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

index a691763..62f61ea 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/84936 - ICE with unexpanded pack in mem-initializer.
+       * parser.c (cp_parser_mem_initializer_list): Call
+       check_for_bare_parameter_packs.
+
 2018-04-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR inline-asm/85172
index f6fbcf6..59eb822 100644 (file)
@@ -14381,10 +14381,15 @@ cp_parser_mem_initializer_list (cp_parser* parser)
       /* Parse the mem-initializer.  */
       mem_initializer = cp_parser_mem_initializer (parser);
       /* If the next token is a `...', we're expanding member initializers. */
-      if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))
+      bool ellipsis = cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS);
+      if (ellipsis
+         || (mem_initializer != error_mark_node
+             && check_for_bare_parameter_packs (TREE_PURPOSE
+                                                (mem_initializer))))
         {
           /* Consume the `...'. */
-          cp_lexer_consume_token (parser->lexer);
+         if (ellipsis)
+           cp_lexer_consume_token (parser->lexer);
 
           /* The TREE_PURPOSE must be a _TYPE, because base-specifiers
              can be expanded but members cannot. */
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic175.C b/gcc/testsuite/g++.dg/cpp0x/variadic175.C
new file mode 100644 (file)
index 0000000..969f4b0
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/84936
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  template<typename... T> A(T... t)
+    : decltype(t)() {} // { dg-error "parameter pack" }
+};
+
+A a;