summaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-26 19:35:33 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-26 19:35:33 +0000
commit1453bbdecd828fb05317fc05ac6a3ac1dc5d9c10 (patch)
tree1db5ca96a007933eeb8608cdeefdc679084e4829 /gcc/tree.c
parent18a5bd9103cd54671ccafddd841d2af24f57af31 (diff)
downloadgcc-1453bbdecd828fb05317fc05ac6a3ac1dc5d9c10.tar.gz
* tree.c (tree_int_cst_lt): Compare constants whose types differ
in unsigned-ness correctly. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52802 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 450dd19cc04..4ec4bd04e86 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);