From d097567da357024ce7863036368e48b0fd4baaaa Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 5 Jan 2010 11:36:45 -0500 Subject: [PATCH] pt.c (unify_pack_expansion): Handle deduction from init-list. * pt.c (unify_pack_expansion): Handle deduction from init-list. * call.c (build_over_call): Don't complain about it. From-SVN: r155653 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/call.c | 6 +++++- gcc/cp/pt.c | 3 +++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/initlist30.C | 12 ++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist30.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 427e57f4f0f..158e80df273 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2010-01-05 Jason Merrill + + * pt.c (unify_pack_expansion): Handle deduction from init-list. + * call.c (build_over_call): Don't complain about it. + 2010-01-04 Jason Merrill PR c++/42555 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 3fcbccf68a3..02fc4b36623 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5665,8 +5665,12 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) tree tmpl = TI_TEMPLATE (cand->template_decl); tree realparm = chain_index (j, DECL_ARGUMENTS (cand->fn)); tree patparm = get_pattern_parm (realparm, tmpl); + tree pattype = TREE_TYPE (patparm); + if (PACK_EXPANSION_P (pattype)) + pattype = PACK_EXPANSION_PATTERN (pattype); + pattype = non_reference (pattype); - if (!is_std_init_list (non_reference (TREE_TYPE (patparm)))) + if (!is_std_init_list (pattype)) { pedwarn (input_location, 0, "deducing %qT as %qT", non_reference (TREE_TYPE (patparm)), diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d2a1f9d6e2e..d8147365fed 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14047,6 +14047,9 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms, if (!skip_arg_p) { + /* For deduction from an init-list we need the actual list. */ + if (arg_expr && BRACE_ENCLOSED_INITIALIZER_P (arg_expr)) + arg = arg_expr; if (unify (tparms, targs, parm, arg, arg_strict)) return 1; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 813e00583af..e137b5be398 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-01-05 Jason Merrill + + * g++.dg/cpp0x/initlist30.C: New test. + 2010-01-05 Richard Guenther PR tree-optimization/42614 diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist30.C b/gcc/testsuite/g++.dg/cpp0x/initlist30.C new file mode 100644 index 00000000000..a5bdb2eda91 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist30.C @@ -0,0 +1,12 @@ +// Testcase for variadic init list deduction. +// { dg-options "-std=c++0x" } + +#include + +template +void f (std::initializer_list... ls); + +int main() +{ + f({1},{2.0}); +}