call.c (struct z_candidate): Add explicit_targs field.
authorJason Merrill <jason@redhat.com>
Mon, 17 May 2010 19:54:05 +0000 (15:54 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 17 May 2010 19:54:05 +0000 (15:54 -0400)
* call.c (struct z_candidate): Add explicit_targs field.
(add_template_candidate_real): Set it.
(build_over_call): Use it to control init-list warning.

From-SVN: r159510

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist34.C

index 6a7a8244158d9e77ba1e3c1ddff68563ee56a9a0..f6515f7d3f7ae15f5511508cde02e20299d6f34d 100644 (file)
@@ -1,5 +1,9 @@
 2010-05-17  Jason Merrill  <jason@redhat.com>
 
+       * call.c (struct z_candidate): Add explicit_targs field.
+       (add_template_candidate_real): Set it.
+       (build_over_call): Use it to control init-list warning.
+
        PR c++/44157
        * call.c (build_over_call): Limit init-list deduction warning to
        cases where the argument is actually an init-list.
index 46779facc555970245eb8c7efc4d713832e8e0f8..97a196b60da8fc70f4f3d08bea93969bd3e66193 100644 (file)
@@ -447,6 +447,7 @@ struct z_candidate {
      indicated by the CONVERSION_PATH.  */
   tree conversion_path;
   tree template_decl;
+  tree explicit_targs;
   candidate_warning *warnings;
   z_candidate *next;
 };
@@ -2573,6 +2574,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
     cand->template_decl = build_template_info (tmpl, targs);
   else
     cand->template_decl = DECL_TEMPLATE_INFO (fn);
+  cand->explicit_targs = explicit_targs;
 
   return cand;
  fail:
@@ -5692,7 +5694,10 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
            pattype = PACK_EXPANSION_PATTERN (pattype);
          pattype = non_reference (pattype);
 
-         if (!is_std_init_list (pattype))
+         if (TREE_CODE (pattype) == TEMPLATE_TYPE_PARM
+             && (cand->explicit_targs == NULL_TREE
+                 || (TREE_VEC_LENGTH (cand->explicit_targs)
+                     <= TEMPLATE_TYPE_IDX (pattype))))
            {
              pedwarn (input_location, 0, "deducing %qT as %qT",
                       non_reference (TREE_TYPE (patparm)),
index aff8d1c6b149da84a989690d2d15814e0a2e8ec9..dfd3823e67c788683e0cb2264b4f2c1c497094de 100644 (file)
@@ -3,8 +3,6 @@
        PR c++/44157
        * g++.dg/cpp0x/initlist34.C: New.
 
-2010-05-17  Jason Merrill  <jason@redhat.com>
-
        PR c++/44158
        * g++.dg/cpp0x/rv-trivial-bug.C: Test copy-init too.
 
index 45cba5637eb10a73db63bb5f4a337e87c2ce251f..92f5a3a4605f0a354d08ac409ef78aeb0e10002c 100644 (file)
@@ -9,4 +9,6 @@ void f(T) { }
 int main() {
   std::initializer_list<int> a = { 0 };
   f(a);
+
+  f<std::initializer_list<int> >({ 0 });
 }