From dcffa15b6e524634316ad09aab3f20869ad05f6e Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Tue, 15 Sep 1992 21:37:22 +0000 Subject: [PATCH 1/1] (int_fits_type_p): Negative ints never fit unsigned types, and unsigned ints with top-bit-set never fit signed types. From-SVN: r2126 --- gcc/tree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/tree.c b/gcc/tree.c index 34de0d6da1ae..4fb48e6780b4 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -3131,10 +3131,12 @@ int_fits_type_p (c, type) { if (TREE_UNSIGNED (type)) return (!INT_CST_LT_UNSIGNED (TYPE_MAX_VALUE (type), c) - && !INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type))); + && !INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type)) + && (TREE_INT_CST_HIGH (c) >= 0 || TREE_UNSIGNED (TREE_TYPE (c)))); else return (!INT_CST_LT (TYPE_MAX_VALUE (type), c) - && !INT_CST_LT (c, TYPE_MIN_VALUE (type))); + && !INT_CST_LT (c, TYPE_MIN_VALUE (type)) + && (TREE_INT_CST_HIGH (c) >= 0 || !TREE_UNSIGNED (TREE_TYPE (c)))); } /* Return the innermost context enclosing DECL that is -- 2.43.5