]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/71833 - member template with two parameter packs
authorJason Merrill <jason@redhat.com>
Tue, 26 Jul 2016 20:29:12 +0000 (16:29 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 26 Jul 2016 20:29:12 +0000 (16:29 -0400)
* pt.c (coerce_template_parameter_pack): Fix logic for
pack index.

From-SVN: r238765

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/variadic-nested1.C [new file with mode: 0644]

index 0b17648eb650559ce70ef4043fa2785089bd9f33..57aeb7aab27b1ff2f19b8b70dcfa0e8aca9fc91b 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/71833
+       * pt.c (coerce_template_parameter_pack): Fix logic for
+       pack index.
+
 2016-07-21  Jason Merrill  <jason@redhat.com>
 
        PR c++/69223
index 6a9f84946188c23c81dcea8e0888dfae1af5fb77..29badc142c6ca319db3372ffb8abc463a51bc401 100644 (file)
@@ -6912,11 +6912,12 @@ coerce_template_parameter_pack (tree parms,
 
   /* Convert the remaining arguments, which will be a part of the
      parameter pack "parm".  */
+  int first_pack_arg = arg_idx;
   for (; arg_idx < nargs; ++arg_idx)
     {
       tree arg = TREE_VEC_ELT (inner_args, arg_idx);
       tree actual_parm = TREE_VALUE (parm);
-      int pack_idx = arg_idx - parm_idx;
+      int pack_idx = arg_idx - first_pack_arg;
 
       if (packed_parms)
         {
@@ -6945,12 +6946,12 @@ coerce_template_parameter_pack (tree parms,
       TREE_VEC_ELT (packed_args, pack_idx) = arg;
     }
 
-  if (arg_idx - parm_idx < TREE_VEC_LENGTH (packed_args)
+  if (arg_idx - first_pack_arg < TREE_VEC_LENGTH (packed_args)
       && TREE_VEC_LENGTH (packed_args) > 0)
     {
       if (complain & tf_error)
        error ("wrong number of template arguments (%d, should be %d)",
-              arg_idx - parm_idx, TREE_VEC_LENGTH (packed_args));
+              arg_idx - first_pack_arg, TREE_VEC_LENGTH (packed_args));
       return error_mark_node;
     }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-nested1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-nested1.C
new file mode 100644 (file)
index 0000000..abfb49a
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/71833
+// { dg-do compile { target c++11 } }
+
+template < typename ... Ts > struct A 
+{
+  template < Ts ..., typename ... Us > struct B {};
+};
+
+A <>::B < int > e;