diff options
author | Charles G Waldman <cgw@alum.mit.edu> | 1999-02-16 00:41:58 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 1999-02-15 17:41:58 -0700 |
commit | 8bbd56856dcc5f73bd0662322805e60e159be353 (patch) | |
tree | 91e9b8d9748714d68afb7086061668a5b0af8fe7 /gcc | |
parent | 20496fa2c8810a2da8d3667e35616999ab6fd8d9 (diff) | |
download | gcc-8bbd56856dcc5f73bd0662322805e60e159be353.zip gcc-8bbd56856dcc5f73bd0662322805e60e159be353.tar.gz gcc-8bbd56856dcc5f73bd0662322805e60e159be353.tar.bz2 |
c-common.c (shorten_compare): Get the min/max value from the underlying type of an enumeration...
* c-common.c (shorten_compare): Get the min/max value from the
underlying type of an enumeration, not the enumerated type itself.
From-SVN: r25228
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-common.c | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 436ec44..b6b1ba2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Tue Feb 16 01:37:33 1999 Charles G Waldman <cgw@alum.mit.edu> + + * c-common.c (shorten_compare): Get the min/max value from the + underlying type of an enumeration, not the enumerated type itself. + Mon Feb 15 23:04:48 1999 Jeffrey A Law (law@cygnus.com) * jump.c: Include insn-attr.h. diff --git a/gcc/c-common.c b/gcc/c-common.c index 5975236..aa94b08 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2406,6 +2406,12 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr) type = signed_or_unsigned_type (unsignedp0, TREE_TYPE (primop0)); + /* If TYPE is an enumeration, then we need to get its min/max + values from it's underlying integral type, not the enumerated + type itself. */ + if (TREE_CODE (type) == ENUMERAL_TYPE) + type = type_for_size (TYPE_PRECISION (type), unsignedp0); + maxval = TYPE_MAX_VALUE (type); minval = TYPE_MIN_VALUE (type); |