aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2002-04-26 19:35:33 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2002-04-26 19:35:33 +0000
commitb13ab42c86156992f0ee15fcf70dfb8cd05fca88 (patch)
tree1db5ca96a007933eeb8608cdeefdc679084e4829 /gcc
parent5e56f90934bee3ddf51271c4246e0f3d331b203e (diff)
downloadgcc-b13ab42c86156992f0ee15fcf70dfb8cd05fca88.zip
gcc-b13ab42c86156992f0ee15fcf70dfb8cd05fca88.tar.gz
gcc-b13ab42c86156992f0ee15fcf70dfb8cd05fca88.tar.bz2
tree.c (tree_int_cst_lt): Compare constants whose types differ in unsigned-ness correctly.
* tree.c (tree_int_cst_lt): Compare constants whose types differ in unsigned-ness correctly. From-SVN: r52802
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/tree.c15
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c87842e..f23a4a4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2002-04-26 Alexandre Oliva <aoliva@redhat.com>
+
+ * tree.c (tree_int_cst_lt): Compare constants whose types differ
+ in unsigned-ness correctly.
+
2002-04-26 John David Anglin <dave@hiauly1.hia.nrc.ca>
* pa.h (FUNCTION_OK_FOR_SIBCALL): Don't do sibcalls when using the
diff --git a/gcc/tree.c b/gcc/tree.c
index 450dd19..4ec4bd0 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3230,7 +3230,20 @@ tree_int_cst_lt (t1, t2)
if (t1 == t2)
return 0;
- if (! TREE_UNSIGNED (TREE_TYPE (t1)))
+ if (TREE_UNSIGNED (TREE_TYPE (t1)) != TREE_UNSIGNED (TREE_TYPE (t2)))
+ {
+ int t1_sgn = tree_int_cst_sgn (t1);
+ int t2_sgn = tree_int_cst_sgn (t2);
+
+ if (t1_sgn < t2_sgn)
+ return 1;
+ else if (t1_sgn > t2_sgn)
+ return 0;
+ /* Otherwise, both are non-negative, so we compare them as
+ unsigned just in case one of them would overflow a signed
+ type. */
+ }
+ else if (! TREE_UNSIGNED (TREE_TYPE (t1)))
return INT_CST_LT (t1, t2);
return INT_CST_LT_UNSIGNED (t1, t2);