public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/71833 (member template with two template parameter packs)
@ 2016-07-25 19:10 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2016-07-25 19:10 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

My patch for 54440 coerce_template_parameter_pack mysteriously assumed
that the index of the first argument we want to pack into the trailing
pack somehow matched the index of the parameter pack in the parameter
list.  I don't know what I was thinking.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 71833.diff --]
[-- Type: text/plain, Size: 1834 bytes --]

commit f4823136e2e9d96fcf25dbb94fcf18c511533dc0
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jul 25 13:06:33 2016 -0400

    	PR c++/71833 - member template with two parameter packs
    
    	* pt.c (coerce_template_parameter_pack): Fix logic for
    	pack index.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a61f1c8..7dd6b25 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7403,11 +7403,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)
         {
@@ -7436,12 +7437,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
index 0000000..abfb49a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-nested1.C
@@ -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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-25 19:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-25 19:10 C++ PATCH for c++/71833 (member template with two template parameter packs) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).