diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ecc83b43a31..d2b2dbea0a6 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 81eaffef57a..7246b13c3d6 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 9c63dbf6448..3ca42825655 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 00000000000..bb67f3e54da --- /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" };