diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-13 19:43:57 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-13 19:43:57 +0000 |
commit | 2419ca22a0d6b2971e1bc1b745ad79868f22751d (patch) | |
tree | d68998d48eccc360e011d67b38b43d76c0f1ee6d | |
parent | 1497da26718af4d132a089bbd9299b26a04ff499 (diff) | |
download | gcc-2419ca22a0d6b2971e1bc1b745ad79868f22751d.tar.gz |
PR c++/52824
* pt.c (any_pack_expanson_args_p): New.
(coerce_template_parms): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186434 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/variadic123.C | 14 |
5 files changed, 40 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e8bcc377fc6..e7e9b7e8afb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-04-13 Jason Merrill <jason@redhat.com> + PR c++/52824 + * pt.c (any_pack_expanson_args_p): New. + (coerce_template_parms): Use it. + PR c++/52905 * call.c (joust): Handle comparing list and non-list ctors. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ee38254bd8c..07a2cc00bb2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6725,6 +6725,20 @@ coerce_template_parameter_pack (tree parms, return argument_pack; } +/* Returns true if the template argument vector ARGS contains + any pack expansions, false otherwise. */ + +static bool +any_pack_expanson_args_p (tree args) +{ + int i; + if (args) + for (i = 0; i < TREE_VEC_LENGTH (args); ++i) + if (PACK_EXPANSION_P (TREE_VEC_ELT (args, i))) + return true; + return false; +} + /* Convert all template arguments to their appropriate types, and return a vector containing the innermost resulting template arguments. If any error occurs, return error_mark_node. Error and @@ -6790,6 +6804,7 @@ coerce_template_parms (tree parms, if ((nargs > nparms && !variadic_p) || (nargs < nparms - variadic_p && require_all_args + && !any_pack_expanson_args_p (inner_args) && (!use_default_args || (TREE_VEC_ELT (parms, nargs) != error_mark_node && !TREE_PURPOSE (TREE_VEC_ELT (parms, nargs)))))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3ea64acfd2..3a31797faeb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2012-04-13 Jason Merrill <jason@redhat.com> + PR c++/52824 + * g++.dg/cpp0x/variadic123.C: New. + * g++.dg/cpp0x/alias-decl-15.C: Remove dg-errors. + PR c++/52905 * g++.dg/cpp0x/initlist-ctor1.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C index 2bc9b11843d..b23e4029f79 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-15.C @@ -2,7 +2,7 @@ // { dg-options "-std=c++0x" } template<class U, class V> //#1 -struct foo {}; // { dg-error "provided for|foo" } +struct foo {}; template<class U, class V=char> struct P {}; @@ -10,8 +10,8 @@ struct P {}; template<template<class... U> class... TT> struct bar { template<class... Args> - using mem = P<TT<Args...>...>;//#2 { dg-error "wrong number of|arguments" } + using mem = P<TT<Args...>...>;//#2 }; -bar<foo>::mem<int, char> b;//#3 { dg-error "invalid type" } +bar<foo>::mem<int, char> b;//#3 diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic123.C b/gcc/testsuite/g++.dg/cpp0x/variadic123.C new file mode 100644 index 00000000000..f0ab9fc22a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic123.C @@ -0,0 +1,14 @@ +// PR c++/52824 +// { dg-do compile { target c++11 } } + +template<typename G, typename H> +struct foo +{}; + +template<typename... G> +struct bar : foo<G...> +{}; + +int main() { + bar<int, float> f; +} |