]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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:40:05 +0000 (17:40 -0700)
committerJeff Law <law@gcc.gnu.org>
Tue, 16 Feb 1999 00:40:05 +0000 (17:40 -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: r25227

gcc/c-common.c

index 5803ab675d37ba20820e9bf1825c678ad820c6eb..61600fb910b6895b9a4e7507567462f267f3f89f 100644 (file)
@@ -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);