aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-04-08 21:57:43 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-04-08 21:57:43 +0000
commit02765a37a16527a510600c206bb0fe176d255525 (patch)
tree07a7d78fde26b05761a85a44a2199eb920893518 /gcc/fold-const.c
parenta0f3928210c3b652eb7804144f59db9f8fe98334 (diff)
downloadgcc-02765a37a16527a510600c206bb0fe176d255525.zip
gcc-02765a37a16527a510600c206bb0fe176d255525.tar.gz
gcc-02765a37a16527a510600c206bb0fe176d255525.tar.bz2
fold-const.c (fold_widened_comparison): Do not allow sign-changes that change the result.
2008-04-08 Richard Guenther <rguenther@suse.de> * fold-const.c (fold_widened_comparison): Do not allow sign-changes that change the result. * gcc.c-torture/execute/20080408-1.c: New testcase. From-SVN: r134108
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 26550b9..66e72a7 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -6721,7 +6721,11 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1)
|| TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type))
&& (TREE_TYPE (arg1_unw) == shorter_type
|| (TYPE_PRECISION (shorter_type)
- >= TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+ > TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+ || ((TYPE_PRECISION (shorter_type)
+ == TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+ && (TYPE_UNSIGNED (shorter_type)
+ == TYPE_UNSIGNED (TREE_TYPE (arg1_unw))))
|| (TREE_CODE (arg1_unw) == INTEGER_CST
&& (TREE_CODE (shorter_type) == INTEGER_TYPE
|| TREE_CODE (shorter_type) == BOOLEAN_TYPE)