OSDN Git Service

PR c++/53498
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Jun 2012 03:42:48 +0000 (03:42 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Jun 2012 03:42:48 +0000 (03:42 +0000)
PR c++/53305
* pt.c (tsubst_pack_expansion): Copy before dummy tsubst.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@188974 138bc75d-0d04-0410-961f-82ee72b054a4

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

index b4588e7..3d9a243 100644 (file)
@@ -1,5 +1,9 @@
 2012-06-25  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53498
+       PR c++/53305
+       * pt.c (tsubst_pack_expansion): Copy before dummy tsubst.
+
        PR c++/52988
        * typeck.c (decay_conversion): Don't discard side-effects from
        expressions of nullptr_t.
index 7f5682d..1b5ab9e 100644 (file)
@@ -9393,7 +9393,9 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
                 late-specified return type).  Even if it exists, it might
                 have the wrong value for a recursive call.  Just make a
                 dummy decl, since it's only used for its type.  */
-             arg_pack = tsubst_decl (parm_pack, args, complain);
+             /* Copy before tsubsting so that we don't recurse into any
+                later PARM_DECLs.  */
+             arg_pack = tsubst_decl (copy_node (parm_pack), args, complain);
              if (arg_pack && FUNCTION_PARAMETER_PACK_P (arg_pack))
                /* Partial instantiation of the parm_pack, we can't build
                   up an argument pack yet.  */
index 67a5a77..82b44a7 100644 (file)
@@ -1,5 +1,10 @@
 2012-06-25  Jason Merrill  <jason@redhat.com>
 
+       PR c++/53498
+       PR c++/53305
+       * g++.dg/cpp0x/decltype38.C: New.
+       * g++.dg/cpp0x/variadic132.C: New.
+
        PR c++/52988
        * g++.dg/cpp0x/nullptr28.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype38.C b/gcc/testsuite/g++.dg/cpp0x/decltype38.C
new file mode 100644 (file)
index 0000000..97ebb33
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/53498
+// { dg-do compile { target c++11 } }
+
+template<typename... Args>
+struct B
+{
+  template<typename U>
+  static
+  void b(const U& u, const Args&... args,
+        decltype(u.f(args...)) dummy)
+  {
+  }
+};
+
+int main() {
+  B<int> b;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic132.C b/gcc/testsuite/g++.dg/cpp0x/variadic132.C
new file mode 100644 (file)
index 0000000..1b9c286
--- /dev/null
@@ -0,0 +1,27 @@
+// PR c++/53305
+// { dg-do compile { target c++11 } }
+
+template<class... Ts> struct tuple { };
+
+struct funct
+{
+  template<class... argTs>
+  int operator()(argTs...);
+};
+
+template<class...> struct test;
+
+template<template <class...> class tp,
+        class... arg1Ts, class... arg2Ts>
+struct test<tp<arg1Ts...>, tp<arg2Ts...>>
+{
+  template<class func, class...arg3Ts>
+    auto test2(func fun, arg1Ts... arg1s, arg3Ts... arg3s)
+    -> decltype(fun(arg1s..., arg3s...));
+};
+
+int main()
+{
+  test<tuple<>, tuple<char,int>> t2;
+  t2.test2(funct(), 'a', 2);
+}