]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
(int_fits_type_p): Negative ints never fit unsigned types, and
authorRichard Kenner <kenner@gcc.gnu.org>
Sat, 2 Aug 1997 22:50:39 +0000 (18:50 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Sat, 2 Aug 1997 22:50:39 +0000 (18:50 -0400)
unsigned ints with top-bit-set never fit signed types.

From-SVN: r14637

gcc/tree.c

index f756d05faa7d1badf44836a43c8f7072d5ea149a..658c05f86840adffad3f7d63d25bbc7557b2e120 100644 (file)
@@ -4346,12 +4346,18 @@ int_fits_type_p (c, type)
     return (! (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
               && INT_CST_LT_UNSIGNED (TYPE_MAX_VALUE (type), c))
            && ! (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
-                 && INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type))));
+                 && INT_CST_LT_UNSIGNED (c, TYPE_MIN_VALUE (type)))
+           /* Negative ints never fit unsigned types.  */
+           && ! (TREE_INT_CST_HIGH (c) < 0
+                 && ! TREE_UNSIGNED (TREE_TYPE (c))));
   else
     return (! (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
               && INT_CST_LT (TYPE_MAX_VALUE (type), c))
            && ! (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
-                 && INT_CST_LT (c, TYPE_MIN_VALUE (type))));
+                 && INT_CST_LT (c, TYPE_MIN_VALUE (type)))
+           /* Unsigned ints with top bit set never fit signed types.  */
+           && ! (TREE_INT_CST_HIGH (c) < 0
+                 && TREE_UNSIGNED (TREE_TYPE (c))));
 }
 
 /* Return the innermost context enclosing DECL that is