re PR c++/52292 ([C++11] Variadic template expansion into fixed template causes const...
authorJason Merrill <jason@redhat.com>
Mon, 16 Apr 2012 03:18:06 +0000 (23:18 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 16 Apr 2012 03:18:06 +0000 (23:18 -0400)
PR c++/52292
PR c++/52380
* pt.c (coerce_template_parms): Even if we aren't converting we
want to expand argument packs.

From-SVN: r186479

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

index 69d5b1d3428edc2ca3ad8278495611d6e747cccb..d37d42c02640ea219d2c5f462156ac7b9f83f820 100644 (file)
@@ -1,5 +1,10 @@
 2012-04-15  Jason Merrill  <jason@redhat.com>
 
+       PR c++/52292
+       PR c++/52380
+       * pt.c (coerce_template_parms): Even if we aren't converting we
+       want to expand argument packs.
+
        PR c++/52706
        * mangle.c (write_type): nullptr_t is a builtin type.
 
index 07a2cc00bb222b5984924ecb71f1230225f0a0ba..42dc0a74439376f186ff3b745d9abe0108782488 100644 (file)
@@ -6882,7 +6882,7 @@ coerce_template_parms (tree parms,
             {
               /* We don't know how many args we have yet, just
                  use the unconverted ones for now.  */
-              new_inner_args = args;
+              new_inner_args = inner_args;
               break;
             }
         }
index f3f68951bf493f7ff62ca6c5d717677bbe16f48f..a936b368ce0046a0a991353f60e5740d834a3432 100644 (file)
@@ -1,5 +1,11 @@
 2012-04-15  Jason Merrill  <jason@redhat.com>
 
+       PR c++/52380
+       * g++.dg/cpp0x/variadic125.C: New.
+
+       PR c++/52292
+       * g++.dg/cpp0x/variadic124.C: New.
+
        PR c++/52706
        * g++.dg/cpp0x/nullptr27.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic124.C b/gcc/testsuite/g++.dg/cpp0x/variadic124.C
new file mode 100644 (file)
index 0000000..8ddc810
--- /dev/null
@@ -0,0 +1,29 @@
+// PR c++/52292
+// { dg-options -std=c++11 }
+
+template <template <typename...> class T>
+struct foo {
+    template <typename... U>
+    foo(T<U...> x) { }
+};
+
+template <typename T>
+struct bar {
+    bar(T x) : value(x) { }
+
+    T value;
+};
+
+struct generic : private foo<bar> {
+    template <typename T>
+    generic(bar<T> x) : foo(x)
+    {
+    }
+
+};
+
+int main()
+{
+    bar<int> x(32);
+    generic y(x); // FAILS
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic125.C b/gcc/testsuite/g++.dg/cpp0x/variadic125.C
new file mode 100644 (file)
index 0000000..89fd6b0
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/52380
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct S
+{
+  template<typename U>
+  struct Unary                        // Line 5
+  {};
+
+  template<unsigned, typename... Args>
+  struct Dispatch                     // Line 9
+    : public Unary<Args...>
+  {};
+
+  template<typename... Args>
+  struct Variadic
+    : public Dispatch<sizeof...(Args), Args...>
+  {};
+};
+
+int main()
+{
+  S<void>::Variadic<void> z;
+}