]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* stmt.c (pushcase_range): Clean up handling of "infinite" values.
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Sun, 8 Feb 1998 23:42:01 +0000 (23:42 +0000)
committerJeff Law <law@gcc.gnu.org>
Sun, 8 Feb 1998 23:42:01 +0000 (16:42 -0700)
From-SVN: r17790

gcc/ChangeLog
gcc/stmt.c

index 2480adb6c4503c91ba73d5ecd00777141773341b..db8209203ae7b25e914d1015f920768fb27a4909 100644 (file)
@@ -5,6 +5,8 @@ Mon Feb  9 00:02:53 1998  Jim Wilson  <wilson@cygnus.com>
 
 Mon Feb  9 00:01:00 1998  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
+       * stmt.c (pushcase_range): Clean up handling of "infinite" values.
+
        * loop.c (strength_reduce): When placing increment for auto-inc
        case, do comparison in loop order.
 
index 8da8ad98ae9177c0fe625528c8a54da6ee171803..573a3f19c3d6ca8c2ceb8691e365d9640eaafecd 100644 (file)
@@ -4538,11 +4538,14 @@ pushcase (value, converter, label, duplicate)
   return 0;
 }
 
-/* Like pushcase but this case applies to all values
-   between VALUE1 and VALUE2 (inclusive).
-   The return value is the same as that of pushcase
-   but there is one additional error code:
-   4 means the specified range was empty.  */
+/* Like pushcase but this case applies to all values between VALUE1 and
+   VALUE2 (inclusive).  If VALUE1 is NULL, the range starts at the lowest
+   value of the index type and ends at VALUE2.  If VALUE2 is NULL, the range
+   starts at VALUE1 and ends at the highest value of the index type.
+   If both are NULL, this case applies to all values.
+
+   The return value is the same as that of pushcase but there is one
+   additional error code: 4 means the specified range was empty.  */
 
 int
 pushcase_range (value1, value2, converter, label, duplicate)
@@ -4560,10 +4563,6 @@ pushcase_range (value1, value2, converter, label, duplicate)
   if (! (case_stack && case_stack->data.case_stmt.start))
     return 1;
 
-  /* Fail if the range is empty.  */
-  if (tree_int_cst_lt (value2, value1))
-    return 4;
-
   if (stack_block_stack
       && stack_block_stack->depth > case_stack->depth)
     return 5;
@@ -4596,20 +4595,28 @@ pushcase_range (value1, value2, converter, label, duplicate)
     }
   case_stack->data.case_stmt.seenlabel = 1;
 
-  /* Convert VALUEs to type in which the comparisons are nominally done.  */
-  if (value1 == 0)  /* Negative infinity.  */
+  /* Convert VALUEs to type in which the comparisons are nominally done
+     and replace any unspecified value with the corresponding bound.  */
+  if (value1 == 0)
     value1 = TYPE_MIN_VALUE (index_type);
-  value1 = (*converter) (nominal_type, value1);
-
-  if (value2 == 0)  /* Positive infinity.  */
+  if (value2 == 0)
     value2 = TYPE_MAX_VALUE (index_type);
+
+  /* Fail if the range is empty.  Do this before any conversion since
+     we want to allow out-of-range empty ranges.  */
+  if (tree_int_cst_lt (value2, value1))
+    return 4;
+
+  value1 = (*converter) (nominal_type, value1);
   value2 = (*converter) (nominal_type, value2);
 
   /* Fail if these values are out of range.  */
-  if (! int_fits_type_p (value1, index_type))
+  if (TREE_CONSTANT_OVERFLOW (value1)
+      || ! int_fits_type_p (value1, index_type))
     return 3;
 
-  if (! int_fits_type_p (value2, index_type))
+  if (TREE_CONSTANT_OVERFLOW (value2)
+      || ! int_fits_type_p (value2, index_type))
     return 3;
 
   return add_case_node (value1, value2, label, duplicate);