]> gcc.gnu.org Git - gcc.git/commitdiff
(int_fits_type_p): Negative ints never fit unsigned
authorRichard Stallman <rms@gnu.org>
Tue, 15 Sep 1992 21:37:22 +0000 (21:37 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 15 Sep 1992 21:37:22 +0000 (21:37 +0000)
types, and unsigned ints with top-bit-set never fit signed types.

From-SVN: r2126

gcc/tree.c

index 34de0d6da1ae9e94aaf4d2a030634dc873a74066..4fb48e6780b44be32c7126ab16c10774c82e802d 100644 (file)
@@ -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
This page took 0.064205 seconds and 5 git commands to generate.