summaryrefslogtreecommitdiffstats
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-16 21:51:57 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-16 21:51:57 +0000
commit0cfec3e9e8d82573065f59c7a32770b458bb1344 (patch)
tree31643f94d1c330d6b0c18e681ad5beb86cc4a269 /gcc/fold-const.c
parentd848c04f47b3d8db8fc0d7ff8edc859367ab545a (diff)
downloadppe42-gcc-0cfec3e9e8d82573065f59c7a32770b458bb1344.tar.gz
ppe42-gcc-0cfec3e9e8d82573065f59c7a32770b458bb1344.zip
2008-01-16 Richard Guenther <rguenther@suse.de>
PR middle-end/32628 * fold-const.c (fold_convert_const_int_from_int): Do not set overflow if that occured only because of a sign extension change when converting from/to a sizetype with the same precision and signedness. * gcc.dg/overflow-warn-7.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131579 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 22350b98bf4..ea0b43e942d 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2122,8 +2122,22 @@ fold_convert_const_int_from_int (tree type, const_tree arg1)
t = force_fit_type_double (type, TREE_INT_CST_LOW (arg1),
TREE_INT_CST_HIGH (arg1),
/* Don't set the overflow when
- converting a pointer */
- !POINTER_TYPE_P (TREE_TYPE (arg1)),
+ converting from a pointer, */
+ !POINTER_TYPE_P (TREE_TYPE (arg1))
+ /* or to a sizetype with same signedness
+ and the precision is unchanged.
+ ??? sizetype is always sign-extended,
+ but its signedness depends on the
+ frontend. Thus we see spurious overflows
+ here if we do not check this. */
+ && !((TYPE_PRECISION (TREE_TYPE (arg1))
+ == TYPE_PRECISION (type))
+ && (TYPE_UNSIGNED (TREE_TYPE (arg1))
+ == TYPE_UNSIGNED (type))
+ && ((TREE_CODE (TREE_TYPE (arg1)) == INTEGER_TYPE
+ && TYPE_IS_SIZETYPE (TREE_TYPE (arg1)))
+ || (TREE_CODE (type) == INTEGER_TYPE
+ && TYPE_IS_SIZETYPE (type)))),
(TREE_INT_CST_HIGH (arg1) < 0
&& (TYPE_UNSIGNED (type)
< TYPE_UNSIGNED (TREE_TYPE (arg1))))
OpenPOWER on IntegriCloud