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]

Re: convert_to_pointer vs partial_int modes


>     case CHAR_TYPE:
>       if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE)
> 	expr = fold_build1 (NOP_EXPR,
>                             lang_hooks.types.type_for_size (POINTER_SIZE, 0),
> 			    expr);
>       return fold_build1 (CONVERT_EXPR, type, expr);

That seems to work for me.  Patch now looks like this:

	* convert.c (convert_to_pointer): Avoid recursion if no
	conversion is needed.

Index: convert.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/convert.c,v
retrieving revision 1.63
diff -p -U3 -r1.63 convert.c
--- convert.c	26 May 2005 04:38:51 -0000	1.63
+++ convert.c	1 Jun 2005 18:11:35 -0000
@@ -42,10 +42,7 @@ tree
 convert_to_pointer (tree type, tree expr)
 {
   if (integer_zerop (expr))
-    {
-      expr = build_int_cst (type, 0);
-      return expr;
-    }
+    return build_int_cst (type, 0);
 
   switch (TREE_CODE (TREE_TYPE (expr)))
     {
@@ -57,13 +54,12 @@ convert_to_pointer (tree type, tree expr
     case ENUMERAL_TYPE:
     case BOOLEAN_TYPE:
     case CHAR_TYPE:
-      if (TYPE_PRECISION (TREE_TYPE (expr)) == POINTER_SIZE)
-	return build1 (CONVERT_EXPR, type, expr);
+      if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE)
+	expr = fold_build1 (NOP_EXPR,
+                            lang_hooks.types.type_for_size (POINTER_SIZE, 0),
+			    expr);
+      return fold_build1 (CONVERT_EXPR, type, expr);
 
-      return
-	convert_to_pointer (type,
-			    convert (lang_hooks.types.type_for_size
-				     (POINTER_SIZE, 0), expr));
 
     default:
       error ("cannot convert to a pointer type");


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