re PR c++/44157 ([C++0x] GCC wrongly takes a std::initializer_list argument as non...
authorJason Merrill <jason@redhat.com>
Mon, 17 May 2010 19:53:55 +0000 (15:53 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 17 May 2010 19:53:55 +0000 (15:53 -0400)
PR c++/44157
* call.c (build_over_call): Limit init-list deduction warning to
cases where the argument is actually an init-list.

From-SVN: r159509

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

index f06c6cd481af9bb06c5b328bf6b92882125498cc..6a7a8244158d9e77ba1e3c1ddff68563ee56a9a0 100644 (file)
@@ -1,5 +1,9 @@
 2010-05-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/44157
+       * call.c (build_over_call): Limit init-list deduction warning to
+       cases where the argument is actually an init-list.
+
        PR c++/44158
        * call.c (build_over_call): Don't do bitwise copy for move ctor.
 
index 5d1300709c9a1d930110b1df27a32332aa797041..46779facc555970245eb8c7efc4d713832e8e0f8 100644 (file)
@@ -5666,6 +5666,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
        parm = TREE_CHAIN (parm), ++arg_index, ++i)
     {
       tree type = TREE_VALUE (parm);
+      tree arg = VEC_index (tree, args, arg_index);
 
       conv = convs[i];
 
@@ -5680,7 +5681,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
       if (cxx_dialect > cxx98
          && flag_deduce_init_list
          && cand->template_decl
-         && is_std_init_list (non_reference (type)))
+         && is_std_init_list (non_reference (type))
+         && BRACE_ENCLOSED_INITIALIZER_P (arg))
        {
          tree tmpl = TI_TEMPLATE (cand->template_decl);
          tree realparm = chain_index (j, DECL_ARGUMENTS (cand->fn));
@@ -5701,9 +5703,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
            }
        }
 
-      val = convert_like_with_context
-       (conv, VEC_index (tree, args, arg_index), fn, i - is_method,
-        complain);
+      val = convert_like_with_context (conv, arg, fn, i-is_method, complain);
 
       val = convert_for_arg_passing (type, val);
       if (val == error_mark_node)
index 67cd4ad1e88f9346e8b71d714bb9821f5159d156..aff8d1c6b149da84a989690d2d15814e0a2e8ec9 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/44157
+       * g++.dg/cpp0x/initlist34.C: New.
+
 2010-05-17  Jason Merrill  <jason@redhat.com>
 
        PR c++/44158
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist34.C b/gcc/testsuite/g++.dg/cpp0x/initlist34.C
new file mode 100644 (file)
index 0000000..45cba56
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/44157
+// { dg-options "-std=c++0x" }
+
+#include <initializer_list>
+
+template<typename T>
+void f(T) { }
+
+int main() {
+  std::initializer_list<int> a = { 0 };
+  f(a);
+}