diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 1997-08-02 22:50:39 +0000 |
---|---|---|
committer | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 1997-08-02 22:50:39 +0000 |
commit | 0d8c4f1301ccd1d5d20487391e50eb6235aaba82 (patch) | |
tree | a70c18d2e75c8534b2bf138f1c9295a458f59432 | |
parent | 960ccb0d8830b2652a6294cbd3564491eb4f61ae (diff) |
(int_fits_type_p): Negative ints never fit unsigned types, and
unsigned ints with top-bit-set never fit signed types.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@14637 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/tree.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index f756d05faa7..658c05f8684 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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 |