This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix c54a13b


The problem here is that types can have non constant min and max
values which cause an ICE in stmt.c where we just use
tree_int_cst_compare instead of checking to make sure that we have
INTEGER_CST.

OK? Bootstrapped and tested on powerpc-darwin (Ada's support
library still not able to build fully here, I just tested
that the testcase now passes).

Thanks,
Andrew Pinski

ChangeLog:
	* stmt.c (add_case_node): Make sure that we have integer
	constant before calling tree_int_cst_compare.

Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.398
diff -u -p -r1.398 stmt.c
--- stmt.c	11 Oct 2004 16:11:29 -0000	1.398
+++ stmt.c	12 Oct 2004 22:19:31 -0000
@@ -2139,8 +2139,10 @@ add_case_node (struct case_node *head, t
   if (!high || tree_int_cst_equal (low, high))
     {
       /* If the simple case value is unreachable, ignore it.  */
-      if (tree_int_cst_compare (low, min_value) < 0
-	  || tree_int_cst_compare (low, max_value) > 0)
+      if ((TREE_CODE (min_value) == INTEGER_CST
+            && tree_int_cst_compare (low, min_value) < 0)
+	  || (TREE_CODE (max_value) == INTEGER_CST
+	      && tree_int_cst_compare (low, max_value) > 0))
 	return head;
       low = fold_convert (type, low);
       high = low;
@@ -2148,19 +2150,23 @@ add_case_node (struct case_node *head, t
   else
     {
       /* If the entire case range is unreachable, ignore it.  */
-      if (tree_int_cst_compare (high, min_value) < 0
-	  || tree_int_cst_compare (low, max_value) > 0)
+      if ((TREE_CODE (min_value) == INTEGER_CST
+            && tree_int_cst_compare (high, min_value) < 0)
+	  || (TREE_CODE (max_value) == INTEGER_CST
+	      && tree_int_cst_compare (low, max_value) > 0))
 	return head;

       /* If the lower bound is less than the index type's minimum
 	 value, truncate the range bounds.  */
-      if (tree_int_cst_compare (low, min_value) < 0)
+      if (TREE_CODE (min_value) == INTEGER_CST
+            && tree_int_cst_compare (low, min_value) < 0)
 	low = min_value;
       low = fold_convert (type, low);

       /* If the upper bound is greater than the index type's maximum
 	 value, truncate the range bounds.  */
-      if (tree_int_cst_compare (high, max_value) > 0)
+      if (TREE_CODE (max_value) == INTEGER_CST
+	  && tree_int_cst_compare (high, max_value) > 0)
 	high = max_value;
       high = fold_convert (type, high);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]