diff options
author | Jason Merrill <jason@redhat.com> | 2009-02-23 15:28:50 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-02-23 15:28:50 -0500 |
commit | 2604de9d9fe19e7a210273e67b3236fa82c571b2 (patch) | |
tree | 1a3cc7b1623659c123b5235692551fce6b5a1b3f /gcc | |
parent | 9283b5133201311b5b62d7f139f3eaa279c2e87d (diff) | |
download | gcc-2604de9d9fe19e7a210273e67b3236fa82c571b2.zip gcc-2604de9d9fe19e7a210273e67b3236fa82c571b2.tar.gz gcc-2604de9d9fe19e7a210273e67b3236fa82c571b2.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist14.C | 19 |
4 files changed, 39 insertions, 2 deletions
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 <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 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 <jason@redhat.com> + + * g++.dg/cpp0x/initlist14.C: New test. + 2008-02-21 Thomas Koenig <tkoenig@gcc.gnu.org> 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 <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" }; |