Lines 4368-4388
cp_build_binary_op (const op_location_t
Link Here
|
4368 |
int converted = 0; |
4368 |
int converted = 0; |
4369 |
|
4369 |
|
4370 |
/* Nonzero means create the expression with this type, rather than |
4370 |
/* Nonzero means create the expression with this type, rather than |
4371 |
RESULT_TYPE. */ |
4371 |
RESULT_TYPE. */ |
4372 |
tree build_type = 0; |
4372 |
tree build_type = 0; |
4373 |
|
4373 |
|
4374 |
/* Nonzero means after finally constructing the expression |
4374 |
/* Nonzero means after finally constructing the expression |
4375 |
convert it to this type. */ |
4375 |
convert it to this type. */ |
4376 |
tree final_type = 0; |
4376 |
tree final_type = 0; |
4377 |
|
4377 |
|
4378 |
tree result, result_ovl; |
4378 |
tree result = NULL, result_ovl; |
4379 |
|
4379 |
|
4380 |
/* Nonzero if this is an operation like MIN or MAX which can |
4380 |
/* Nonzero if this is an operation like MIN or MAX which can |
4381 |
safely be computed in short if both args are promoted shorts. |
4381 |
safely be computed in short if both args are promoted shorts. |
4382 |
Also implies COMMON. |
4382 |
Also implies COMMON. |
4383 |
-1 indicates a bitwise operation; this makes a difference |
4383 |
-1 indicates a bitwise operation; this makes a difference |
4384 |
in the exact conditions for when it is safe to do the operation |
4384 |
in the exact conditions for when it is safe to do the operation |
4385 |
in a narrower mode. */ |
4385 |
in a narrower mode. */ |
4386 |
int shorten = 0; |
4386 |
int shorten = 0; |
4387 |
|
4387 |
|
4388 |
/* Nonzero if this is a comparison operation; |
4388 |
/* Nonzero if this is a comparison operation; |
Lines 5544-5564
cp_build_binary_op (const op_location_t
Link Here
|
5544 |
if (TREE_TYPE (cop0) != orig_type) |
5544 |
if (TREE_TYPE (cop0) != orig_type) |
5545 |
cop0 = cp_convert (orig_type, op0, complain); |
5545 |
cop0 = cp_convert (orig_type, op0, complain); |
5546 |
if (TREE_TYPE (cop1) != orig_type) |
5546 |
if (TREE_TYPE (cop1) != orig_type) |
5547 |
cop1 = cp_convert (orig_type, op1, complain); |
5547 |
cop1 = cp_convert (orig_type, op1, complain); |
5548 |
instrument_expr = ubsan_instrument_division (location, cop0, cop1); |
5548 |
instrument_expr = ubsan_instrument_division (location, cop0, cop1); |
5549 |
} |
5549 |
} |
5550 |
else if (doing_shift && sanitize_flags_p (SANITIZE_SHIFT)) |
5550 |
else if (doing_shift && sanitize_flags_p (SANITIZE_SHIFT)) |
5551 |
instrument_expr = ubsan_instrument_shift (location, code, op0, op1); |
5551 |
instrument_expr = ubsan_instrument_shift (location, code, op0, op1); |
5552 |
} |
5552 |
} |
5553 |
|
5553 |
|
5554 |
result = build2_loc (location, resultcode, build_type, op0, op1); |
5554 |
// FIXME: vectors and complex as well |
|
|
5555 |
if (flag_rounding_math && SCALAR_FLOAT_TYPE_P (build_type)) |
5556 |
{ |
5557 |
bool do_fenv_subst = true; |
5558 |
internal_fn ifn; |
5559 |
switch (resultcode) |
5560 |
{ |
5561 |
case PLUS_EXPR: |
5562 |
ifn = IFN_FENV_PLUS; |
5563 |
break; |
5564 |
case MINUS_EXPR: |
5565 |
ifn = IFN_FENV_MINUS; |
5566 |
break; |
5567 |
case MULT_EXPR: |
5568 |
ifn = IFN_FENV_MULT; |
5569 |
break; |
5570 |
case RDIV_EXPR: |
5571 |
ifn = IFN_FENV_DIV; |
5572 |
break; |
5573 |
default: |
5574 |
do_fenv_subst = false; |
5575 |
} |
5576 |
if (do_fenv_subst) |
5577 |
return build_call_expr_internal_loc (location, ifn, build_type, |
5578 |
2, op0, op1); |
5579 |
} |
5580 |
|
5581 |
if (!result) |
5582 |
result = build2_loc (location, resultcode, build_type, op0, op1); |
5555 |
if (final_type != 0) |
5583 |
if (final_type != 0) |
5556 |
result = cp_convert (final_type, result, complain); |
5584 |
result = cp_convert (final_type, result, complain); |
5557 |
|
5585 |
|
5558 |
if (instrument_expr != NULL) |
5586 |
if (instrument_expr != NULL) |
5559 |
result = build2 (COMPOUND_EXPR, TREE_TYPE (result), |
5587 |
result = build2 (COMPOUND_EXPR, TREE_TYPE (result), |
5560 |
instrument_expr, result); |
5588 |
instrument_expr, result); |
5561 |
|
5589 |
|
5562 |
if (!processing_template_decl) |
5590 |
if (!processing_template_decl) |
5563 |
{ |
5591 |
{ |
5564 |
op0 = cp_fully_fold (op0); |
5592 |
op0 = cp_fully_fold (op0); |