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 a691763669f3126df8f4b45a9c32f097d426a1a0..62f61eab345425c93d005fe5d162eec13afed69d 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 f6fbcf6185e4cd6f5dbf804cfa566fbdc2f3952a..59eb822611244d5b2edea1dd3cfbf50daf475e6e 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;