From: Richard Stallman Date: Tue, 15 Sep 1992 21:37:22 +0000 (+0000) Subject: (int_fits_type_p): Negative ints never fit unsigned X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dcffa15b6e524634316ad09aab3f20869ad05f6e;p=gcc.git (int_fits_type_p): Negative ints never fit unsigned types, and unsigned ints with top-bit-set never fit signed types. From-SVN: r2126 --- diff --git a/gcc/tree.c b/gcc/tree.c index 34de0d6da1a..4fb48e6780b 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