aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>2003-03-19 13:19:53 -0500
committerJason Merrill <jason@gcc.gnu.org>2003-03-19 13:19:53 -0500
commitb9747e59d60160903cd366f342ddb5cb960b9944 (patch)
tree7950655295f16a8c523a857a20f9b0d20ec6753c /gcc/cp
parent9eb0ef7a07219dd4e4bfd6f8c3cd216e0a250367 (diff)
downloadgcc-b9747e59d60160903cd366f342ddb5cb960b9944.zip
gcc-b9747e59d60160903cd366f342ddb5cb960b9944.tar.gz
gcc-b9747e59d60160903cd366f342ddb5cb960b9944.tar.bz2
PR c++/8316, c++/9315, c++/10136
PR c++/8316, c++/9315, c++/10136 * call.c (print_z_candidate): Split out from... (print_z_candidiates): ...here. (joust): Use it. From-SVN: r64590
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/call.c59
2 files changed, 44 insertions, 23 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 25cc235..de07dfe 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,13 @@
+2003-03-19 Jason Merrill <jason@redhat.com>
+
+ 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 <roger@eyesopen.com>
+ 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 9ed804b..7119234 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) <built-in>", 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) <built-in>", str, candidate->fn,
+ TREE_TYPE (TREE_VEC_ELT (candidate->convs, 0)),
+ TREE_TYPE (TREE_VEC_ELT (candidate->convs, 1)));
+ else
+ errfn ("%s %D(%T) <built-in>", str, candidate->fn,
+ TREE_TYPE (TREE_VEC_ELT (candidate->convs, 0)));
+ }
+ else if (TYPE_P (candidate->fn))
+ errfn ("%s %T <conversion>", str, candidate->fn);
+ else
+ errfn ("%H%s %+#D%s", &DECL_SOURCE_LOCATION (candidate->fn), str,
+ candidate->fn, candidate->viable == -1 ? " <near match>" : "");
+}
+
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) <built-in>", 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) <built-in>", str, candidates->fn,
- TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)),
- TREE_TYPE (TREE_VEC_ELT (candidates->convs, 1)));
- else
- error ("%s %D(%T) <built-in>", str, candidates->fn,
- TREE_TYPE (TREE_VEC_ELT (candidates->convs, 0)));
- }
- else if (TYPE_P (candidates->fn))
- error ("%s %T <conversion>", str, candidates->fn);
- else
- cp_error_at ("%s %+#D%s", str, candidates->fn,
- candidates->viable == -1 ? " <near match>" : "");
+ 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);