From 5f0fc83311a043deb76a57ce6689c4579354ae48 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 23 Feb 2009 20:28:50 +0000 Subject: [PATCH] * pt.c (unify): Call maybe_adjust_types_for_deduction when deducing from an initializer list. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144392 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 13 +++++++++++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/initlist14.C | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist14.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ecc83b4..d2b2dbe 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2009-02-23 Jason Merrill + + * pt.c (unify): Call maybe_adjust_types_for_deduction when + deducing from an initializer list. + 2009-02-20 Jason Merrill PR c++/39225 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 81eaffe..7246b13 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13204,9 +13204,18 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict) FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (arg), i, elt) { + int elt_strict = strict; if (!BRACE_ENCLOSED_INITIALIZER_P (elt)) - elt = TREE_TYPE (elt); - if (unify (tparms, targs, elttype, elt, UNIFY_ALLOW_NONE)) + { + tree type = TREE_TYPE (elt); + /* It should only be possible to get here for a call. */ + gcc_assert (elt_strict & UNIFY_ALLOW_OUTER_LEVEL); + elt_strict |= maybe_adjust_types_for_deduction + (DEDUCE_CALL, &elttype, &type, elt); + elt = type; + } + + if (unify (tparms, targs, elttype, elt, elt_strict)) return 1; } return 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9c63dbf..3ca4282 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-02-23 Jason Merrill + + * g++.dg/cpp0x/initlist14.C: New test. + 2008-02-21 Thomas Koenig PR fortran/38914 diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist14.C b/gcc/testsuite/g++.dg/cpp0x/initlist14.C new file mode 100644 index 0000000..bb67f3e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist14.C @@ -0,0 +1,19 @@ +// Bug: We weren't doing the normal replacement of array with pointer +// for deduction in the context of a call because of the initializer list. +// { dg-options "-std=c++0x" } + +#include + +struct string +{ + string (const char *); +}; + +template +struct vector +{ + template + vector (std::initializer_list); +}; + +vector v = { "a", "b", "c" }; -- 2.7.4