diff options
Diffstat (limited to 'gcc/cp/call.cc')
-rw-r--r-- | gcc/cp/call.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 37ad0a9..c76b15b 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -4927,6 +4927,11 @@ implicit_conversion_error (location_t loc, tree type, tree expr) && !CP_AGGREGATE_TYPE_P (type)) error_at (loc, "designated initializers cannot be used with a " "non-aggregate type %qT", type); + else if (is_stub_object (expr)) + /* The expression is generated by a trait check, we don't have + a useful location to highlight the label. */ + error_at (loc, "could not convert %qH to %qI", + TREE_TYPE (expr), type); else { range_label_for_type_mismatch label (TREE_TYPE (expr), type); @@ -7536,7 +7541,9 @@ build_new_op (const op_location_t &loc, enum tree_code code, int flags, if (cand->rewritten ()) { /* FIXME build_min_non_dep_op_overload can't handle rewrites. */ - if (overload) + if (code == NE_EXPR && !cand->reversed ()) + /* It can handle != rewritten to == though. */; + else if (overload) *overload = NULL_TREE; switch (code) { @@ -8696,6 +8703,7 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, diagnostic_t diag_kind; int flags; location_t loc = cp_expr_loc_or_input_loc (expr); + const bool stub_object_p = is_stub_object (expr); if (convs->bad_p && !(complain & tf_error)) return error_mark_node; @@ -8772,7 +8780,10 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, "from %qH to %qI", TREE_TYPE (expr), totype); if (complained) - print_z_candidate (loc, N_("candidate is:"), t->cand); + { + auto_diagnostic_nesting_level sentinel; + print_z_candidate (loc, N_("candidate is:"), t->cand); + } expr = convert_like (t, expr, fn, argnum, /*issue_conversion_warnings=*/false, /*c_cast_p=*/false, /*nested_p=*/true, @@ -8797,7 +8808,14 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, else if (t->kind == ck_identity) break; } - if (!complained && expr != error_mark_node) + if (!complained && stub_object_p) + { + /* An error diagnosed within a trait, don't give extra labels. */ + error_at (loc, "invalid conversion from %qH to %qI", + TREE_TYPE (expr), totype); + complained = 1; + } + else if (!complained && expr != error_mark_node) { range_label_for_type_mismatch label (TREE_TYPE (expr), totype); gcc_rich_location richloc (loc, &label, highlight_colors::percent_h); |