c90-const-expr-8.c: Look for overflow on INT_MIN % -1.
2013-11-27 Kenneth Zadeck <zadeck@naturalbridge.com> * gcc.dg/c90-const-expr-8.c: Look for overflow on INT_MIN % -1. * gcc.dg/c99-const-expr-8.c: Look for overflow on INT_MIN % -1. 2013-11-27 Kenneth Zadeck <zadeck@naturalbridge.com> * fold-const.c (int_const_binop_1): Make INT_MIN % -1 return 0 with the overflow bit set. From-SVN: r205448
This commit is contained in:
parent
e9287a41df
commit
2e25208425
5 changed files with 31 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
2013-11-27 Kenneth Zadeck <zadeck@naturalbridge.com>
|
||||
|
||||
* fold-const.c
|
||||
(int_const_binop_1): Make INT_MIN % -1 return 0 with the overflow
|
||||
bit set.
|
||||
|
||||
2013-11-27 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR middle-end/58723
|
||||
|
|
|
@ -1110,7 +1110,22 @@ int_const_binop_1 (enum tree_code code, const_tree arg1, const_tree arg2,
|
|||
case ROUND_MOD_EXPR:
|
||||
if (op2.is_zero ())
|
||||
return NULL_TREE;
|
||||
tmp = op1.divmod_with_overflow (op2, uns, code, &res, &overflow);
|
||||
|
||||
/* Check for the case the case of INT_MIN % -1 and return
|
||||
overflow and result = 0. The TImode case is handled properly
|
||||
in double-int. */
|
||||
if (TYPE_PRECISION (type) <= HOST_BITS_PER_WIDE_INT
|
||||
&& !uns
|
||||
&& op2.is_minus_one ()
|
||||
&& op1.high == (HOST_WIDE_INT) -1
|
||||
&& (HOST_WIDE_INT) op1.low
|
||||
== (((HOST_WIDE_INT)-1) << (TYPE_PRECISION (type) - 1)))
|
||||
{
|
||||
overflow = 1;
|
||||
res = double_int_zero;
|
||||
}
|
||||
else
|
||||
tmp = op1.divmod_with_overflow (op2, uns, code, &res, &overflow);
|
||||
break;
|
||||
|
||||
case MIN_EXPR:
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2013-11-27 Kenneth Zadeck <zadeck@naturalbridge.com>
|
||||
|
||||
* gcc.dg/c90-const-expr-8.c: Look for overflow on INT_MIN % -1.
|
||||
* gcc.dg/c99-const-expr-8.c: Look for overflow on INT_MIN % -1.
|
||||
|
||||
2013-11-27 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/59306
|
||||
|
|
|
@ -23,5 +23,6 @@ enum e {
|
|||
/* { dg-error "3:overflow in constant expression" "constant" { target *-*-* } 22 } */
|
||||
E6 = 0 * !-INT_MIN, /* { dg-warning "13:integer overflow in expression" } */
|
||||
/* { dg-error "8:not an integer constant" "constant" { target *-*-* } 24 } */
|
||||
E7 = INT_MIN % -1 /* Not an overflow. */
|
||||
E7 = INT_MIN % -1 /* { dg-warning "16:integer overflow in expression" } */
|
||||
/* { dg-error "1:overflow in constant expression" "constant" { target *-*-* } 28 } */
|
||||
};
|
||||
|
|
|
@ -23,5 +23,6 @@ enum e {
|
|||
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 22 } */
|
||||
E6 = 0 * !-INT_MIN, /* { dg-warning "integer overflow in expression" } */
|
||||
/* { dg-error "not an integer constant" "constant" { target *-*-* } 24 } */
|
||||
E7 = INT_MIN % -1 /* Not an overflow. */
|
||||
E7 = INT_MIN % -1 /* { dg-warning "16:integer overflow in expression" } */
|
||||
/* { dg-error "1:overflow in constant expression" "constant" { target *-*-* } 28 } */
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue