}
}
+/* 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
/*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)
{
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);
}
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;
/* 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:
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;
}
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;
}