diff options
author | Olivier Hainque <hainque@adacore.com> | 2009-07-27 17:40:57 +0000 |
---|---|---|
committer | Douglas Rupp <rupp@gcc.gnu.org> | 2009-07-27 17:40:57 +0000 |
commit | cf157324f383a7bfb6504e8ec20d8d0a569ac43b (patch) | |
tree | 81c4ef5de4cb28ea7e21c57ebc69d82ebbf4a588 | |
parent | d4d798a3717d7ba938eab6d98b87b07242a6dc13 (diff) | |
download | gcc-cf157324f383a7bfb6504e8ec20d8d0a569ac43b.zip gcc-cf157324f383a7bfb6504e8ec20d8d0a569ac43b.tar.gz gcc-cf157324f383a7bfb6504e8ec20d8d0a569ac43b.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/convert.c | 19 |
2 files changed, 20 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 97d5555..f3f0cdb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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> * system.h (fopen): Undefine if macro. diff --git a/gcc/convert.c b/gcc/convert.c index a1ac330..f7ddfc9 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"); |