pt.c (unify): Call maybe_adjust_types_for_deduction when deducing from an initializer list.
* pt.c (unify): Call maybe_adjust_types_for_deduction when deducing from an initializer list. From-SVN: r144392
This commit is contained in:
parent
9283b51332
commit
2604de9d9f
4 changed files with 39 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
2009-02-23 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* pt.c (unify): Call maybe_adjust_types_for_deduction when
|
||||
deducing from an initializer list.
|
||||
|
||||
2009-02-20 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/39225
|
||||
|
|
13
gcc/cp/pt.c
13
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;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2009-02-23 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* g++.dg/cpp0x/initlist14.C: New test.
|
||||
|
||||
2008-02-21 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/38914
|
||||
|
|
19
gcc/testsuite/g++.dg/cpp0x/initlist14.C
Normal file
19
gcc/testsuite/g++.dg/cpp0x/initlist14.C
Normal file
|
@ -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 <initializer_list>
|
||||
|
||||
struct string
|
||||
{
|
||||
string (const char *);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct vector
|
||||
{
|
||||
template <class U>
|
||||
vector (std::initializer_list<U>);
|
||||
};
|
||||
|
||||
vector<string> v = { "a", "b", "c" };
|
Loading…
Add table
Reference in a new issue