call.c (print_error_for_call_failure): Say "no match" rather than "ambiguous" if...
authorJason Merrill <jason@redhat.com>
Tue, 13 May 2014 21:10:03 +0000 (17:10 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 May 2014 21:10:03 +0000 (17:10 -0400)
* call.c (print_error_for_call_failure): Say "no match" rather
than "ambiguous" if there were no strict matches.
(build_new_method_call_1): Likewise.

From-SVN: r210402

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

index a26472c..70a167f 100644 (file)
@@ -1,5 +1,9 @@
 2014-05-13  Jason Merrill  <jason@redhat.com>
 
+       * call.c (print_error_for_call_failure): Say "no match" rather
+       than "ambiguous" if there were no strict matches.
+       (build_new_method_call_1): Likewise.
+
        PR c++/61151
        * semantics.c (is_this_parameter): Allow capture proxies too.
 
index 7b8bc09..d8a7dcd 100644 (file)
@@ -3914,13 +3914,13 @@ perform_overload_resolution (tree fn,
    functions.  */
 
 static void
-print_error_for_call_failure (tree fn, vec<tree, va_gc> *args, bool any_viable_p,
+print_error_for_call_failure (tree fn, vec<tree, va_gc> *args,
                              struct z_candidate *candidates)
 {
   tree name = DECL_NAME (OVL_CURRENT (fn));
   location_t loc = location_of (name);
 
-  if (!any_viable_p)
+  if (!any_strictly_viable (candidates))
     error_at (loc, "no matching function for call to %<%D(%A)%>",
              name, build_tree_list_vec (args));
   else
@@ -3964,7 +3964,7 @@ build_new_function_call (tree fn, vec<tree, va_gc> **args, bool koenig_p,
       if (!fn)
        {
          if (complain & tf_error)
-           print_error_for_call_failure (orig_fn, *args, false, NULL);
+           print_error_for_call_failure (orig_fn, *args, NULL);
          return error_mark_node;
        }
     }
@@ -3984,7 +3984,7 @@ build_new_function_call (tree fn, vec<tree, va_gc> **args, bool koenig_p,
            return cp_build_function_call_vec (candidates->fn, args, complain);
          if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
            fn = TREE_OPERAND (fn, 0);
-         print_error_for_call_failure (fn, *args, any_viable_p, candidates);
+         print_error_for_call_failure (fn, *args, candidates);
        }
       result = error_mark_node;
     }
@@ -4066,7 +4066,7 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args,
   if (!cand)
     {
       if (complain & tf_error)
-       print_error_for_call_failure (fns, *args, any_viable_p, candidates);
+       print_error_for_call_failure (fns, *args, candidates);
       return error_mark_node;
     }
 
@@ -7898,8 +7898,12 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
              arglist = build_tree_list_vec (user_args);
              if (skip_first_for_error)
                arglist = TREE_CHAIN (arglist);
-             error ("call of overloaded %<%s(%A)%> is ambiguous", pretty_name,
-                    arglist);
+             if (!any_strictly_viable (candidates))
+               error ("no matching function for call to %<%s(%A)%>",
+                      pretty_name, arglist);
+             else
+               error ("call of overloaded %<%s(%A)%> is ambiguous",
+                      pretty_name, arglist);
              print_z_candidates (location_of (name), candidates);
              if (free_p)
                free (pretty_name);
index 289cffb..5444c78 100644 (file)
@@ -492,7 +492,7 @@ int test2_67()
     const          A ca = a; // { dg-error "deleted" }
           volatile A va;
     const volatile A cva = a; // { dg-error "deleted" }
-    sink_2_67(a);            // { dg-error "ambiguous" }
+    sink_2_67(a);            // { dg-error "no match" }
     // { dg-message "candidate" "candidate note" { target *-*-* } 495 }
     sink_2_67(ca);          // { dg-error "lvalue" }
     sink_2_67(va);          // { dg-error "lvalue" }
index 765dfbc..3a729cb 100644 (file)
@@ -930,7 +930,7 @@ int test3_678()
     const          A ca = a; // { dg-error "deleted" }
           volatile A va;
     const volatile A cva = a; // { dg-error "deleted" }
-    sink_3_678(a);          // { dg-error "ambiguous" }
+    sink_3_678(a);          // { dg-error "no match" }
     // { dg-message "candidate" "candidate note" { target *-*-* } 933 }
     sink_3_678(ca);        // { dg-error "lvalue" }
     sink_3_678(va);        // { dg-error "lvalue" }