From: Jason Merrill Date: Tue, 13 May 2014 21:10:03 +0000 (-0400) Subject: call.c (print_error_for_call_failure): Say "no match" rather than "ambiguous" if... X-Git-Tag: releases/gcc-5.1.0~7601 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c29f393f8326d3e4ec0a7841e8f3c45137f62795;p=thirdparty%2Fgcc.git call.c (print_error_for_call_failure): Say "no match" rather than "ambiguous" if there were no strict matches. * 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a26472c333f9..70a167faad29 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-05-13 Jason Merrill + * 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. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 7b8bc09cb289..d8a7dcd776a0 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3914,13 +3914,13 @@ perform_overload_resolution (tree fn, functions. */ static void -print_error_for_call_failure (tree fn, vec *args, bool any_viable_p, +print_error_for_call_failure (tree fn, vec *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 **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 **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 **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 **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); diff --git a/gcc/testsuite/g++.dg/cpp0x/rv2n.C b/gcc/testsuite/g++.dg/cpp0x/rv2n.C index 289cffb181c9..5444c782f1a3 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv2n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv2n.C @@ -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" } diff --git a/gcc/testsuite/g++.dg/cpp0x/rv3n.C b/gcc/testsuite/g++.dg/cpp0x/rv3n.C index 765dfbc7f224..3a729cb21652 100644 --- a/gcc/testsuite/g++.dg/cpp0x/rv3n.C +++ b/gcc/testsuite/g++.dg/cpp0x/rv3n.C @@ -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" }