From: Charles G Waldman Date: Tue, 16 Feb 1999 00:40:05 +0000 (-0700) Subject: c-common.c (shorten_compare): Get the min/max value from the underlying type of an... X-Git-Tag: prereleases/egcs-1.1.2-prerelease-1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f47bc2e9cd3d8db6d2b691fa07426aa67282de8;p=thirdparty%2Fgcc.git 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: r25227 --- diff --git a/gcc/c-common.c b/gcc/c-common.c index 5803ab675d37..61600fb910b6 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2284,6 +2284,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);