mirror of git://gcc.gnu.org/git/gcc.git
re PR middle-end/37261 (Spurious (?) "integer overflow in expression" warnings)
PR c/37261 * fold-const.c (fold_binary): In (X | C1) & C2 canonicalization compute new & and | in type rather than TREE_TYPE (arg0). * gcc.dg/pr37261.c: New test. From-SVN: r139784
This commit is contained in:
parent
98c0cbd30a
commit
bf09f0e0e9
|
@ -1,5 +1,9 @@
|
||||||
2008-08-29 Jakub Jelinek <jakub@redhat.com>
|
2008-08-29 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c/37261
|
||||||
|
* fold-const.c (fold_binary): In (X | C1) & C2 canonicalization
|
||||||
|
compute new & and | in type rather than TREE_TYPE (arg0).
|
||||||
|
|
||||||
* dwarf2out.c (fortran_common): Update comment.
|
* dwarf2out.c (fortran_common): Update comment.
|
||||||
(gen_variable_die): Swap com_die and var_die variables in Fortran
|
(gen_variable_die): Swap com_die and var_die variables in Fortran
|
||||||
COMMON block handling code.
|
COMMON block handling code.
|
||||||
|
|
|
@ -10737,14 +10737,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
|
||||||
&& TREE_CODE (arg1) == INTEGER_CST
|
&& TREE_CODE (arg1) == INTEGER_CST
|
||||||
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
|
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
|
||||||
{
|
{
|
||||||
tree tmp1 = fold_convert (TREE_TYPE (arg0), arg1);
|
tree tmp1 = fold_convert (type, arg1);
|
||||||
tree tmp2 = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0),
|
tree tmp2 = fold_convert (type, TREE_OPERAND (arg0, 0));
|
||||||
TREE_OPERAND (arg0, 0), tmp1);
|
tree tmp3 = fold_convert (type, TREE_OPERAND (arg0, 1));
|
||||||
tree tmp3 = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0),
|
tmp2 = fold_build2 (BIT_AND_EXPR, type, tmp2, tmp1);
|
||||||
TREE_OPERAND (arg0, 1), tmp1);
|
tmp3 = fold_build2 (BIT_AND_EXPR, type, tmp3, tmp1);
|
||||||
return fold_convert (type,
|
return fold_convert (type,
|
||||||
fold_build2 (BIT_IOR_EXPR, TREE_TYPE (arg0),
|
fold_build2 (BIT_IOR_EXPR, type, tmp2, tmp3));
|
||||||
tmp2, tmp3));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (X | Y) & Y is (X, Y). */
|
/* (X | Y) & Y is (X, Y). */
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
2008-08-22 Jakub Jelinek <jakub@redhat.com>
|
2008-08-29 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR c/37261
|
||||||
|
* gcc.dg/pr37261.c: New test.
|
||||||
|
|
||||||
PR fortran/23057
|
PR fortran/23057
|
||||||
* gfortran.dg/debug/pr35154-dwarf2.f: Adjust for replacement
|
* gfortran.dg/debug/pr35154-dwarf2.f: Adjust for replacement
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
/* PR c/37261 */
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O2 -fdump-tree-optimized" } */
|
||||||
|
|
||||||
|
unsigned
|
||||||
|
foo (int x)
|
||||||
|
{
|
||||||
|
unsigned a = ((x & 1) | 2) & 0x80000000; /* { dg-bogus "integer overflow in expression" } */
|
||||||
|
unsigned b = ((x & 2) | 2) & 0x80000000; /* { dg-bogus "integer overflow in expression" } */
|
||||||
|
unsigned c = ((x & 4) | 2) & 0x80000000; /* { dg-bogus "integer overflow in expression" } */
|
||||||
|
return a + b + c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { dg-final { scan-tree-dump "return 0" "optimized" } } */
|
||||||
|
/* { dg-final { cleanup-tree-dump "optimized" } } */
|
Loading…
Reference in New Issue