From 36a01cad6bf9b76dceb6c1f18c633efa147b918b Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 17 May 2010 19:53:55 +0000 Subject: [PATCH] PR c++/44157 * call.c (build_over_call): Limit init-list deduction warning to cases where the argument is actually an init-list. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159509 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/call.c | 8 ++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/initlist34.C | 12 ++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist34.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f06c6cd481a..6a7a8244158 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2010-05-17 Jason Merrill + PR c++/44157 + * call.c (build_over_call): Limit init-list deduction warning to + cases where the argument is actually an init-list. + PR c++/44158 * call.c (build_over_call): Don't do bitwise copy for move ctor. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 5d1300709c9..46779facc55 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5666,6 +5666,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) parm = TREE_CHAIN (parm), ++arg_index, ++i) { tree type = TREE_VALUE (parm); + tree arg = VEC_index (tree, args, arg_index); conv = convs[i]; @@ -5680,7 +5681,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) if (cxx_dialect > cxx98 && flag_deduce_init_list && cand->template_decl - && is_std_init_list (non_reference (type))) + && is_std_init_list (non_reference (type)) + && BRACE_ENCLOSED_INITIALIZER_P (arg)) { tree tmpl = TI_TEMPLATE (cand->template_decl); tree realparm = chain_index (j, DECL_ARGUMENTS (cand->fn)); @@ -5701,9 +5703,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) } } - val = convert_like_with_context - (conv, VEC_index (tree, args, arg_index), fn, i - is_method, - complain); + val = convert_like_with_context (conv, arg, fn, i-is_method, complain); val = convert_for_arg_passing (type, val); if (val == error_mark_node) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 67cd4ad1e88..aff8d1c6b14 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2010-05-17 Jason Merrill + PR c++/44157 + * g++.dg/cpp0x/initlist34.C: New. + +2010-05-17 Jason Merrill + PR c++/44158 * g++.dg/cpp0x/rv-trivial-bug.C: Test copy-init too. diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist34.C b/gcc/testsuite/g++.dg/cpp0x/initlist34.C new file mode 100644 index 00000000000..45cba5637eb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist34.C @@ -0,0 +1,12 @@ +// PR c++/44157 +// { dg-options "-std=c++0x" } + +#include + +template +void f(T) { } + +int main() { + std::initializer_list a = { 0 }; + f(a); +} -- 2.11.0