c-typeck.c (build_c_cast): Try using a shared constant...
2005-11-07 Paolo Bonzini <bonzini@gnu.org> * c-typeck.c (build_c_cast): Try using a shared constant, and see if TREE_OVERFLOW or TREE_CONSTANT_OVERFLOW really changed. testsuite: 2005-11-07 Paolo Bonzini <bonzini@gnu.org> * gcc.dg/overflow-2.c: New testcase. From-SVN: r106587
This commit is contained in:
parent
ab900bfa4d
commit
d8e1f97b7e
@ -1,3 +1,8 @@
|
||||
2005-11-07 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* c-typeck.c (build_c_cast): Try using a shared constant, and see
|
||||
if TREE_OVERFLOW or TREE_CONSTANT_OVERFLOW really changed.
|
||||
|
||||
2005-11-07 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR rtl-optimization/23567
|
||||
|
@ -3500,16 +3500,19 @@ build_c_cast (tree type, tree expr)
|
||||
/* Ignore any integer overflow caused by the cast. */
|
||||
if (TREE_CODE (value) == INTEGER_CST)
|
||||
{
|
||||
/* If OVALUE had overflow set, then so will VALUE, so it
|
||||
is safe to overwrite. */
|
||||
if (CONSTANT_CLASS_P (ovalue))
|
||||
if (CONSTANT_CLASS_P (ovalue)
|
||||
&& (TREE_OVERFLOW (ovalue) || TREE_CONSTANT_OVERFLOW (ovalue)))
|
||||
{
|
||||
/* Avoid clobbering a shared constant. */
|
||||
value = copy_node (value);
|
||||
TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
|
||||
/* Similarly, constant_overflow cannot have become cleared. */
|
||||
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
|
||||
}
|
||||
else
|
||||
TREE_OVERFLOW (value) = 0;
|
||||
else if (TREE_OVERFLOW (value) || TREE_CONSTANT_OVERFLOW (value))
|
||||
/* Reset VALUE's overflow flags, ensuring constant sharing. */
|
||||
value = build_int_cst_wide (TREE_TYPE (value),
|
||||
TREE_INT_CST_LOW (value),
|
||||
TREE_INT_CST_HIGH (value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2005-11-07 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* gcc.dg/overflow-2.c: New testcase.
|
||||
|
||||
2005-11-07 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR rtl-optimization/23567
|
||||
|
13
gcc/testsuite/gcc.dg/overflow-2.c
Normal file
13
gcc/testsuite/gcc.dg/overflow-2.c
Normal file
@ -0,0 +1,13 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c99 -pedantic-errors" } */
|
||||
|
||||
/* PR c/24599 */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
if ((_Bool)(__INT_MAX__ + 1)) /* { dg-warning "overflow in expression" } */
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user