From f341b42a79b99705b90354b935d575b0912bfc97 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 19 Mar 2003 18:19:53 +0000 Subject: [PATCH] PR c++/8316, c++/9315, c++/10136 * call.c (print_z_candidate): Split out from... (print_z_candidiates): ...here. (joust): Use it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64590 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/call.c | 59 ++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 25cc235962c..de07dfe5122 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,13 @@ +2003-03-19 Jason Merrill + + PR c++/8316, c++/9315, c++/10136 + * call.c (print_z_candidate): Split out from... + (print_z_candidiates): ...here. + (joust): Use it. + 2003-03-17 Roger Sayle + PR c++/10031 * decl.c (duplicate_decls): Use the new type when prototyping anticipated decls, even when the types match. This defines the exception list for the built-in function. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 9ed804b439d..71192343e42 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -2435,6 +2435,36 @@ equal_functions (tree fn1, tree fn2) return fn1 == fn2; } +/* Print information about one overload candidate CANDIDATE. STR is the + text to print before the candidate itself and ERRFN is the routine + (i.e. error, warning or pedwarn) used to do the printing. */ + +static void +print_z_candidate (const char *str, struct z_candidate *candidate, + void (*errfn)(const char *, ...)) +{ + if (TREE_CODE (candidate->fn) == IDENTIFIER_NODE) + { + if (TREE_VEC_LENGTH (candidate->convs) == 3) + errfn ("%s %D(%T, %T, %T) ", str, candidate->fn, + TREE_TYPE (TREE_VEC_ELT (candidate->convs, 0)), + TREE_TYPE (TREE_VEC_ELT (candidate->convs, 1)), + TREE_TYPE (TREE_VEC_ELT (candidate->convs, 2))); + else if (TREE_VEC_LENGTH (candidate->convs) == 2) + errfn ("%s %D(%T, %T) ", str, candidate->fn, + TREE_TYPE (TREE_VEC_ELT (candidate->convs, 0)), + TREE_TYPE (TREE_VEC_ELT (candidate->convs, 1))); + else + errfn ("%s %D(%T) ", str, candidate->fn, + TREE_TYPE (TREE_VEC_ELT (candidate->convs, 0))); + } + else if (TYPE_P (candidate->fn)) + errfn ("%s %T ", str, candidate->fn); + else + errfn ("%H%s %+#D%s", &DECL_SOURCE_LOCATION (candidate->fn), str, + candidate->fn, candidate->viable == -1 ? " " : ""); +} + static void print_z_candidates (struct z_candidate *candidates) { @@ -2467,26 +2497,7 @@ print_z_candidates (struct z_candidate *candidates) str = "candidates are:"; for (; candidates; candidates = candidates->next) { - if (TREE_CODE (candidates->fn) == IDENTIFIER_NODE) - { - if (TREE_VEC_LENGTH (candidates->convs) == 3) - error ("%s %D(%T, %T, %T) ", str, candidates->fn, - TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)), - TREE_TYPE (TREE_VEC_ELT (candidates->convs, 1)), - TREE_TYPE (TREE_VEC_ELT (candidates->convs, 2))); - else if (TREE_VEC_LENGTH (candidates->convs) == 2) - error ("%s %D(%T, %T) ", str, candidates->fn, - TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)), - TREE_TYPE (TREE_VEC_ELT (candidates->convs, 1))); - else - error ("%s %D(%T) ", str, candidates->fn, - TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0))); - } - else if (TYPE_P (candidates->fn)) - error ("%s %T ", str, candidates->fn); - else - cp_error_at ("%s %+#D%s", str, candidates->fn, - candidates->viable == -1 ? " " : ""); + print_z_candidate (str, candidates, error); str = " "; } } @@ -5861,9 +5872,11 @@ tweak: { if (warn) { - pedwarn ("choosing `%D' over `%D'", w->fn, l->fn); - pedwarn ( -" because worst conversion for the former is better than worst conversion for the latter"); + print_z_candidate ("ISO C++ says that ", w, pedwarn); + print_z_candidate (" and ", l, pedwarn); + pedwarn ("are ambiguous even though the worst conversion \ +for the former is better than the worst conversion for the latter", + w->fn, l->fn); } else add_warning (w, l); -- 2.11.0