OSDN Git Service

* pt.c (unify_pack_expansion): Handle deduction from init-list.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jan 2010 16:36:45 +0000 (16:36 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 5 Jan 2010 16:36:45 +0000 (16:36 +0000)
* call.c (build_over_call): Don't complain about it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155653 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist30.C [new file with mode: 0644]

index 427e57f..158e80d 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-05  Jason Merrill  <jason@redhat.com>
+
+       * pt.c (unify_pack_expansion): Handle deduction from init-list.
+       * call.c (build_over_call): Don't complain about it.
+
 2010-01-04  Jason Merrill  <jason@redhat.com>
 
        PR c++/42555
index 3fcbccf..02fc4b3 100644 (file)
@@ -5665,8 +5665,12 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
          tree tmpl = TI_TEMPLATE (cand->template_decl);
          tree realparm = chain_index (j, DECL_ARGUMENTS (cand->fn));
          tree patparm = get_pattern_parm (realparm, tmpl);
+         tree pattype = TREE_TYPE (patparm);
+         if (PACK_EXPANSION_P (pattype))
+           pattype = PACK_EXPANSION_PATTERN (pattype);
+         pattype = non_reference (pattype);
 
-         if (!is_std_init_list (non_reference (TREE_TYPE (patparm))))
+         if (!is_std_init_list (pattype))
            {
              pedwarn (input_location, 0, "deducing %qT as %qT",
                       non_reference (TREE_TYPE (patparm)),
index d2a1f9d..d814736 100644 (file)
@@ -14047,6 +14047,9 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
 
         if (!skip_arg_p)
           {
+           /* For deduction from an init-list we need the actual list.  */
+           if (arg_expr && BRACE_ENCLOSED_INITIALIZER_P (arg_expr))
+             arg = arg_expr;
             if (unify (tparms, targs, parm, arg, arg_strict))
               return 1;
           }
index 813e005..e137b5b 100644 (file)
@@ -1,3 +1,7 @@
+2010-01-05  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/initlist30.C: New test.
+
 2010-01-05  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/42614
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist30.C b/gcc/testsuite/g++.dg/cpp0x/initlist30.C
new file mode 100644 (file)
index 0000000..a5bdb2e
--- /dev/null
@@ -0,0 +1,12 @@
+// Testcase for variadic init list deduction.
+// { dg-options "-std=c++0x" }
+
+#include <initializer_list>
+
+template <class... Ts>
+void f (std::initializer_list<Ts>... ls);
+
+int main()
+{
+  f({1},{2.0});
+}