OSDN Git Service

* config.gcc (vax-*-linux*): Keep the original contents of
[pf3gnuchains/gcc-fork.git] / gcc / convert.c
index a833418..453f5ed 100644 (file)
@@ -54,7 +54,17 @@ convert_to_pointer (tree type, tree expr)
     {
     case POINTER_TYPE:
     case REFERENCE_TYPE:
-      return fold_build1_loc (loc, NOP_EXPR, type, expr);
+      {
+        /* If the pointers point to different address spaces, conversion needs
+          to be done via a ADDR_SPACE_CONVERT_EXPR instead of a NOP_EXPR.  */
+       addr_space_t to_as = TYPE_ADDR_SPACE (TREE_TYPE (type));
+       addr_space_t from_as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (expr)));
+
+       if (to_as == from_as)
+         return fold_build1_loc (loc, NOP_EXPR, type, expr);
+       else
+         return fold_build1_loc (loc, ADDR_SPACE_CONVERT_EXPR, type, expr);
+      }
 
     case INTEGER_TYPE:
     case ENUMERAL_TYPE: