Commit e564cf98 by Jason Merrill Committed by Jason Merrill

Revert "Fix conversions for built-in operator overloading candidates."

This reverts commit 948d5b831affef14a49f56804b01e3f1ba00cdb3.

From-SVN: r275976
parent b3c4d0dd
2019-09-19 Jason Merrill <jason@redhat.com>
Revert:
* call.c (build_new_op_1): Don't apply any standard conversions to
the operands of a built-in operator. Don't suppress conversions in
cp_build_unary_op.
* typeck.c (cp_build_unary_op): Do integral promotions for enums.
2019-09-16 Paolo Carlini <paolo.carlini@oracle.com> 2019-09-16 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (grokdeclarator): Use declspecs->locations and * decl.c (grokdeclarator): Use declspecs->locations and
......
...@@ -6142,40 +6142,41 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, ...@@ -6142,40 +6142,41 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags,
break; break;
} }
/* "If a built-in candidate is selected by overload resolution, the /* We need to strip any leading REF_BIND so that bitfields
operands of class type are converted to the types of the don't cause errors. This should not remove any important
corresponding parameters of the selected operation function, conversions, because builtins don't apply to class
except that the second standard conversion sequence of a objects directly. */
user-defined conversion sequence (12.3.3.1.2) is not applied." */
conv = cand->convs[0]; conv = cand->convs[0];
if (conv->user_conv_p) if (conv->kind == ck_ref_bind)
{ conv = next_conversion (conv);
while (conv->kind != ck_user) arg1 = convert_like (conv, arg1, complain);
conv = next_conversion (conv);
arg1 = convert_like (conv, arg1, complain);
}
if (arg2) if (arg2)
{ {
conv = cand->convs[1]; conv = cand->convs[1];
if (conv->user_conv_p) if (conv->kind == ck_ref_bind)
{ conv = next_conversion (conv);
while (conv->kind != ck_user) else
conv = next_conversion (conv); arg2 = decay_conversion (arg2, complain);
arg2 = convert_like (conv, arg2, complain);
}
}
/* We need to call warn_logical_operator before
converting arg2 to a boolean_type, but after
decaying an enumerator to its value. */
if (complain & tf_warning)
warn_logical_operator (loc, code, boolean_type_node,
code_orig_arg1, arg1,
code_orig_arg2, arg2);
arg2 = convert_like (conv, arg2, complain);
}
if (arg3) if (arg3)
{ {
conv = cand->convs[2]; conv = cand->convs[2];
if (conv->user_conv_p) if (conv->kind == ck_ref_bind)
{ conv = next_conversion (conv);
while (conv->kind != ck_user) convert_like (conv, arg3, complain);
conv = next_conversion (conv);
arg3 = convert_like (conv, arg3, complain);
}
} }
} }
} }
...@@ -6243,7 +6244,7 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags, ...@@ -6243,7 +6244,7 @@ build_new_op_1 (const op_location_t &loc, enum tree_code code, int flags,
case REALPART_EXPR: case REALPART_EXPR:
case IMAGPART_EXPR: case IMAGPART_EXPR:
case ABS_EXPR: case ABS_EXPR:
return cp_build_unary_op (code, arg1, false, complain); return cp_build_unary_op (code, arg1, candidates != 0, complain);
case ARRAY_REF: case ARRAY_REF:
return cp_build_array_ref (input_location, arg1, arg2, complain); return cp_build_array_ref (input_location, arg1, arg2, complain);
......
...@@ -6249,7 +6249,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, ...@@ -6249,7 +6249,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
: _("wrong type argument to unary plus")); : _("wrong type argument to unary plus"));
else else
{ {
if (!noconvert && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (arg))) if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg)))
arg = cp_perform_integral_promotions (arg, complain); arg = cp_perform_integral_promotions (arg, complain);
/* Make sure the result is not an lvalue: a unary plus or minus /* Make sure the result is not an lvalue: a unary plus or minus
...@@ -6274,7 +6274,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, ...@@ -6274,7 +6274,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
| WANT_VECTOR_OR_COMPLEX, | WANT_VECTOR_OR_COMPLEX,
arg, true))) arg, true)))
errstring = _("wrong type argument to bit-complement"); errstring = _("wrong type argument to bit-complement");
else if (!noconvert && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (arg))) else if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg)))
{ {
/* Warn if the expression has boolean value. */ /* Warn if the expression has boolean value. */
if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment