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] treat OFFSET_TYPE like POINTER_TYPE in fold_convert


While working on PR 15881, I noticed that fold_convert was not ICEing
on when the orginal type was OFFSET_TYPE.  This fixes this ICE as
fold_convert should treat it just like POINTER_TYPE and INTEGER_TYPE.

OK? Bootstrapped on powerpc-apple-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
	* fold-const.c (fold_convert): Treat OFFSET_TYPE like
	POINTER_TYPE and INTEGER_TYPE.

Patch:
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.213.2.65.2.7
diff -u -p -r1.213.2.65.2.7 fold-const.c
--- fold-const.c	30 May 2004 09:32:33 -0000	1.213.2.65.2.7
+++ fold-const.c	8 Jun 2004 21:45:14 -0000
@@ -1897,7 +1897,8 @@ fold_convert (tree type, tree arg)
   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig))
     return fold (build1 (NOP_EXPR, type, arg));
 
-  if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type))
+  if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)
+      || TREE_CODE (type) == OFFSET_TYPE)
     {
       if (TREE_CODE (arg) == INTEGER_CST)
 	{
@@ -1905,7 +1906,8 @@ fold_convert (tree type, tree arg)
 	  if (tem != NULL_TREE)
 	    return tem;
 	}
-      if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig))
+      if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig)
+	  || TREE_CODE (orig) == OFFSET_TYPE)
         return fold (build1 (NOP_EXPR, type, arg));
       if (TREE_CODE (orig) == COMPLEX_TYPE)
 	{


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