We already had code to deal with an unexpanded pack in the
initializer, but not in the member designator.  If we find one, let's
pretend it was expanded.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit cb6bcd45b6bd3c1edc44ad0fbe164135cb17467b
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed Apr 4 15:43:21 2018 -0400

            PR c++/84936 - ICE with unexpanded pack in mem-initializer.
    
            * parser.c (cp_parser_mem_initializer_list): Call
            check_for_bare_parameter_packs.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index f6fbcf6185e..59eb8226112 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
index 00000000000..969f4b0b152
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic175.C
@@ -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;

Reply via email to