OSDN Git Service

* pt.c (unify): Call maybe_adjust_types_for_deduction when
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Feb 2009 20:28:50 +0000 (20:28 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Feb 2009 20:28:50 +0000 (20:28 +0000)
        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
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist14.C [new file with mode: 0644]

index ecc83b4..d2b2dbe 100644 (file)
@@ -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
index 81eaffe..7246b13 100644 (file)
@@ -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;
index 9c63dbf..3ca4282 100644 (file)
@@ -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 (file)
index 0000000..bb67f3e
--- /dev/null
@@ -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" };