aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r--gcc/cp/typeck.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 7b653ceb..8955442 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4848,7 +4848,7 @@ cp_build_binary_op (const op_location_t &location,
}
else
{
- if (!integer_zerop (op1))
+ if (!integer_zerop (const_op1))
short_shift = 1;
if (compare_tree_int (const_op1, TYPE_PRECISION (type0)) >= 0
@@ -5599,6 +5599,7 @@ cp_build_binary_op (const op_location_t &location,
{
int unsigned_arg;
tree arg0 = get_narrower (op0, &unsigned_arg);
+ tree const_op1 = cp_fold_rvalue (op1);
final_type = result_type;
@@ -5606,10 +5607,11 @@ cp_build_binary_op (const op_location_t &location,
unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0));
if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
- && tree_int_cst_sgn (op1) > 0
+ && tree_int_cst_sgn (const_op1) > 0
/* We can shorten only if the shift count is less than the
number of bits in the smaller type size. */
- && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0
+ && compare_tree_int (const_op1,
+ TYPE_PRECISION (TREE_TYPE (arg0))) < 0
/* We cannot drop an unsigned shift after sign-extension. */
&& (!TYPE_UNSIGNED (final_type) || unsigned_arg))
{