OSDN Git Service

* convert.c (convert_to_pointer): Avoid recursion if no conversion
authordj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Jun 2005 22:02:59 +0000 (22:02 +0000)
committerdj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Jun 2005 22:02:59 +0000 (22:02 +0000)
is needed.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100518 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/convert.c

index 2f1cc16..98bc4c2 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-02  DJ Delorie  <dj@redhat.com>
+
+       * convert.c (convert_to_pointer): Avoid recursion if no conversion
+       is needed.
+
 2005-06-02  Richard Guenther  <rguenth@gcc.gnu.org>
 
        * tree-chrec.c (chrec_fold_plus_1): Ensure we build
index fbd18de..dc9f41f 100644 (file)
@@ -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");