diff options
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/convert.c | 16 |
2 files changed, 11 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2f1cc1660f7..98bc4c2bd26 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/convert.c b/gcc/convert.c index fbd18dee23e..dc9f41f648a 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -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"); |