From ada30930a12b07dac1ea7e5d76fab3f184823243 Mon Sep 17 00:00:00 2001 From: rupp Date: Mon, 27 Jul 2009 17:40:57 +0000 Subject: * convert.c (convert_to_pointer): Don't assume the target pointer type is POINTER_SIZE long. Fetch its precision instead. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150133 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/convert.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'gcc/convert.c') diff --git a/gcc/convert.c b/gcc/convert.c index a1ac3300cac..f7ddfc956fc 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -59,12 +59,21 @@ convert_to_pointer (tree type, tree expr) case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: - if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE) - expr = fold_build1_loc (loc, NOP_EXPR, - lang_hooks.types.type_for_size (POINTER_SIZE, 0), - expr); - return fold_build1_loc (loc, CONVERT_EXPR, type, expr); + { + /* If the input precision differs from the target pointer type + precision, first convert the input expression to an integer type of + the target precision. Some targets, e.g. VMS, need several pointer + 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: error ("cannot convert to a pointer type"); -- cgit v1.2.1