summaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-13 03:21:18 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-13 03:21:18 +0000
commit2371bf7cac40c5af4c7867f1ace23bb2992bd828 (patch)
tree102aa271ca8cf4ca179b73c122387fe10f0cf260 /gcc/cp/call.c
parent7ba8c6df70adc47513b3b182ad479d123114b69a (diff)
downloadgcc-2371bf7cac40c5af4c7867f1ace23bb2992bd828.tar.gz
* call.c (maybe_print_user_conv_context): New.
(convert_like_real): Use it. Print call context for bad user-defined conversion. (build_over_call): Print call context for bad 'this' conversion. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210350 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f2ceef24781..7b8bc09cb28 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5942,6 +5942,23 @@ conversion_null_warnings (tree totype, tree expr, tree fn, int argnum)
}
}
+/* We gave a diagnostic during a conversion. If this was in the second
+ standard conversion sequence of a user-defined conversion sequence, say
+ which user-defined conversion. */
+
+static void
+maybe_print_user_conv_context (conversion *convs)
+{
+ if (convs->user_conv_p)
+ for (conversion *t = convs; t; t = next_conversion (t))
+ if (t->kind == ck_user)
+ {
+ print_z_candidate (0, " after user-defined conversion:",
+ t->cand);
+ break;
+ }
+}
+
/* Perform the conversions in CONVS on the expression EXPR. FN and
ARGNUM are used for diagnostics. ARGNUM is zero based, -1
indicates the `this' argument of a method. INNER is nonzero when
@@ -6003,11 +6020,15 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
/*c_cast_p=*/false,
complain);
if (convs->kind == ck_ref_bind)
- return convert_to_reference (totype, expr, CONV_IMPLICIT,
+ expr = convert_to_reference (totype, expr, CONV_IMPLICIT,
LOOKUP_NORMAL, NULL_TREE,
complain);
else
- return cp_convert (totype, expr, complain);
+ expr = cp_convert (totype, expr, complain);
+ if (fn)
+ inform (DECL_SOURCE_LOCATION (fn),
+ " initializing argument %P of %qD", argnum, fn);
+ return expr;
}
else if (t->kind == ck_user || !t->bad_p)
{
@@ -6030,7 +6051,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
TREE_TYPE (expr), totype);
if (complained && fn)
inform (DECL_SOURCE_LOCATION (fn),
- "initializing argument %P of %qD", argnum, fn);
+ " initializing argument %P of %qD", argnum, fn);
return cp_convert (totype, expr, complain);
}
@@ -6135,7 +6156,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
build_user_type_conversion (totype, convs->u.expr, LOOKUP_NORMAL,
complain);
if (fn)
- inform (input_location, "initializing argument %P of %q+D",
+ inform (input_location, " initializing argument %P of %q+D",
argnum, fn);
}
return error_mark_node;
@@ -6255,9 +6276,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
/* Copy-list-initialization doesn't actually involve a copy. */
return expr;
expr = build_temp (expr, totype, flags, &diag_kind, complain);
- if (diag_kind && fn && complain)
- inform (DECL_SOURCE_LOCATION (fn),
- " initializing argument %P of %qD", argnum, fn);
+ if (diag_kind && complain)
+ {
+ maybe_print_user_conv_context (convs);
+ if (fn)
+ inform (DECL_SOURCE_LOCATION (fn),
+ " initializing argument %P of %qD", argnum, fn);
+ }
+
return build_cplus_new (totype, expr, complain);
case ck_ref_bind:
@@ -6272,9 +6298,10 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
error_at (loc, "cannot bind %qT lvalue to %qT",
TREE_TYPE (expr), totype);
+ maybe_print_user_conv_context (convs);
if (fn)
inform (input_location,
- "initializing argument %P of %q+D", argnum, fn);
+ " initializing argument %P of %q+D", argnum, fn);
return error_mark_node;
}
@@ -6935,8 +6962,12 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
if (convs[i]->bad_p)
{
if (complain & tf_error)
- permerror (input_location, "passing %qT as %<this%> argument of %q#D discards qualifiers",
- TREE_TYPE (argtype), fn);
+ {
+ if (permerror (input_location, "passing %qT as %<this%> "
+ "argument discards qualifiers",
+ TREE_TYPE (argtype)))
+ inform (DECL_SOURCE_LOCATION (fn), " in call to %qD", fn);
+ }
else
return error_mark_node;
}