aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-05-26 09:22:51 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-05-26 09:22:51 -0400
commitb613992600ec23a017a1c1d2c82adf0fe06cdd92 (patch)
tree032f35fe761d116c8c7bbd078092468e73c62951 /gcc
parentd11bf18f560999725b1fbbb393f7d12a1b751a59 (diff)
downloadgcc-b613992600ec23a017a1c1d2c82adf0fe06cdd92.zip
gcc-b613992600ec23a017a1c1d2c82adf0fe06cdd92.tar.gz
gcc-b613992600ec23a017a1c1d2c82adf0fe06cdd92.tar.bz2
re PR c++/48424 (C++0x parameter packs expansion problem)
PR c++/48424 * decl.c (grokparms): Function parameter packs don't need to go at the end. * pt.c (type_unification_real): But they aren't deduced otherwise. From-SVN: r174285
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/cp/pt.c19
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic111.C19
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic41.C13
6 files changed, 59 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 582935c..de154ae 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2011-05-26 Jason Merrill <jason@redhat.com>
+
+ PR c++/48424
+ * decl.c (grokparms): Function parameter packs don't need to
+ go at the end.
+ * pt.c (type_unification_real): But they aren't deduced otherwise.
+
2011-05-25 Jason Merrill <jason@redhat.com>
PR c++/48536
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8ab0c8a..a956dbb 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10551,12 +10551,6 @@ grokparms (tree parmlist, tree *parms)
init = check_default_argument (decl, init);
}
- if (TREE_CODE (decl) == PARM_DECL
- && FUNCTION_PARAMETER_PACK_P (decl)
- && TREE_CHAIN (parm)
- && TREE_CHAIN (parm) != void_list_node)
- error ("parameter packs must be at the end of the parameter list");
-
DECL_CHAIN (decl) = decls;
decls = decl;
result = tree_cons (init, type, result);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c9c25cd2..ab48c8f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14262,11 +14262,24 @@ type_unification_real (tree tparms,
while (parms && parms != void_list_node
&& ia < nargs)
{
- if (TREE_CODE (TREE_VALUE (parms)) == TYPE_PACK_EXPANSION)
- break;
-
parm = TREE_VALUE (parms);
+
+ if (TREE_CODE (parm) == TYPE_PACK_EXPANSION
+ && (!TREE_CHAIN (parms) || TREE_CHAIN (parms) == void_list_node))
+ /* For a function parameter pack that occurs at the end of the
+ parameter-declaration-list, the type A of each remaining
+ argument of the call is compared with the type P of the
+ declarator-id of the function parameter pack. */
+ break;
+
parms = TREE_CHAIN (parms);
+
+ if (TREE_CODE (parm) == TYPE_PACK_EXPANSION)
+ /* For a function parameter pack that does not occur at the
+ end of the parameter-declaration-list, the type of the
+ parameter pack is a non-deduced context. */
+ continue;
+
arg = args[ia];
++ia;
arg_expr = NULL;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 089406d..7e71ee2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-26 Jason Merrill <jason@redhat.com>
+
+ * g++.dg/cpp0x/variadic111.C: New.
+ * g++.dg/cpp0x/variadic41.C: Adjust.
+
2011-05-26 Richard Guenther <rguenther@suse.de>
PR tree-optimization/48702
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic111.C b/gcc/testsuite/g++.dg/cpp0x/variadic111.C
new file mode 100644
index 0000000..378162e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic111.C
@@ -0,0 +1,19 @@
+// PR c++/48424
+// { dg-options -std=c++0x }
+
+template<typename... Args1>
+struct S
+{
+ template<typename... Args2>
+ void f(Args1... args1, Args2&&... args2)
+ {
+ }
+};
+
+int main()
+{
+ S<int, double> s;
+ s.f(1,2.0,false,'a');
+}
+
+// { dg-final { scan-assembler "_ZN1SIIidEE1fIIbcEEEvidDpOT_" } }
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic41.C b/gcc/testsuite/g++.dg/cpp0x/variadic41.C
index d209766..9cfd847 100644
--- a/gcc/testsuite/g++.dg/cpp0x/variadic41.C
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic41.C
@@ -1,3 +1,14 @@
+// A function parameter pack is only deduced if it's at the end
// { dg-options "-std=gnu++0x" }
template<typename... Args>
-void f(const Args&... args, int oops); // { dg-error "end" }
+void f(const Args&... args, int oops);
+
+int main()
+{
+ f<>(1);
+ f(1);
+ f<int>(1,2);
+ f(1,2); // { dg-error "no match" }
+}
+
+// { dg-prune-output "note" }