c-common.c (shorten_compare): Get the min/max value from the underlying type of an...
authorCharles G Waldman <cgw@alum.mit.edu>
Tue, 16 Feb 1999 00:41:58 +0000 (00:41 +0000)
committerJeff Law <law@gcc.gnu.org>
Tue, 16 Feb 1999 00:41:58 +0000 (17:41 -0700)
        * 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

gcc/ChangeLog
gcc/c-common.c

index 436ec440504e4a5aa3c3150420a199181191e8c8..b6b1ba2aae22b06c235f6238fab2e2d76100dc2b 100644 (file)
@@ -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.
index 5975236a3931260c27b5041c5ef7b3f096e87b63..aa94b087989caa9ff3b2d5172b53b85e0f5e3864 100644 (file)
@@ -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);