Commit cf157324 by Olivier Hainque Committed by Douglas Rupp

convert.c (convert_to_pointer): Don't assume the target pointer type is POINTER_SIZE long.


	* convert.c (convert_to_pointer): Don't assume the target
	pointer type is POINTER_SIZE long. Fetch its precision instead.


Co-Authored-By: Douglas B Rupp <rupp@gnat.com>

From-SVN: r150133
parent d4d798a3
2009-07-27 Olivier Hainque <hainque@adacore.com>
Douglas B Rupp <rupp@gnat.com>
* convert.c (convert_to_pointer): Don't assume the target
pointer type is POINTER_SIZE long. Fetch its precision instead.
2009-07-27 Douglas B Rupp <rupp@gnat.com> 2009-07-27 Douglas B Rupp <rupp@gnat.com>
* system.h (fopen): Undefine if macro. * system.h (fopen): Undefine if macro.
......
...@@ -59,12 +59,21 @@ convert_to_pointer (tree type, tree expr) ...@@ -59,12 +59,21 @@ convert_to_pointer (tree type, tree expr)
case INTEGER_TYPE: case INTEGER_TYPE:
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
case BOOLEAN_TYPE: case BOOLEAN_TYPE:
if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE) {
expr = fold_build1_loc (loc, NOP_EXPR, /* If the input precision differs from the target pointer type
lang_hooks.types.type_for_size (POINTER_SIZE, 0), precision, first convert the input expression to an integer type of
expr); the target precision. Some targets, e.g. VMS, need several pointer
return fold_build1_loc (loc, CONVERT_EXPR, type, expr); sizes to coexist so the latter isn't necessarily POINTER_SIZE. */
unsigned int pprec = TYPE_PRECISION (type);
unsigned int eprec = TYPE_PRECISION (TREE_TYPE (expr));
if (eprec != pprec)
expr = fold_build1_loc (loc, NOP_EXPR,
lang_hooks.types.type_for_size (pprec, 0),
expr);
}
return fold_build1_loc (loc, CONVERT_EXPR, type, expr);
default: default:
error ("cannot convert to a pointer type"); error ("cannot convert to a pointer type");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment