diff options
author | Richard Stallman <rms@gnu.org> | 1993-11-04 19:38:34 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1993-11-04 19:38:34 +0000 |
commit | 5c28da2454101fb1e45eb9b89985b0f15a0e58b5 (patch) | |
tree | df86e864da0f7be6d1f36f955f467858acaf3ecc /gcc | |
parent | e5884dacd58235ba11d43a627087fbb36d1d55ad (diff) | |
download | gcc-5c28da2454101fb1e45eb9b89985b0f15a0e58b5.zip gcc-5c28da2454101fb1e45eb9b89985b0f15a0e58b5.tar.gz gcc-5c28da2454101fb1e45eb9b89985b0f15a0e58b5.tar.bz2 |
(finish_enum): Always make an enum signed if it will fit.
From-SVN: r5996
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-decl.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index bb2ad12..26a0bfb 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5566,8 +5566,12 @@ finish_enum (enumtype, values) TYPE_SIZE (enumtype) = 0; layout_type (enumtype); - /* An enum can have some negative values; then it is signed. */ - TREE_UNSIGNED (enumtype) = ! tree_int_cst_lt (minnode, integer_zero_node); + /* If an enum has no negative values, and it goes beyond the range + of the signed integral type, make it unsigned. */ + TREE_UNSIGNED (enumtype) + = (! tree_int_cst_lt (minnode, integer_zero_node) + && ! tree_int_cst_lt (maxnode, + TYPE_MAX_VALUE (type_for_size (precision, 0)))); /* Change the type of the enumerators to be the enum type. Formerly this was done only for enums that fit in an int, |