From: DJ Delorie Date: Thu, 2 Jun 2005 22:02:59 +0000 (-0400) Subject: convert.c (convert_to_pointer): Avoid recursion if no conversion is needed. X-Git-Tag: misc/cutover-cvs2svn~2681 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e9cd9d8aa3ccfe72fecce5f2ab4419c6028d52d;p=thirdparty%2Fgcc.git convert.c (convert_to_pointer): Avoid recursion if no conversion is needed. * convert.c (convert_to_pointer): Avoid recursion if no conversion is needed. From-SVN: r100518 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2f1cc1660f79..98bc4c2bd268 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-06-02 DJ Delorie + + * convert.c (convert_to_pointer): Avoid recursion if no conversion + is needed. + 2005-06-02 Richard Guenther * tree-chrec.c (chrec_fold_plus_1): Ensure we build diff --git a/gcc/convert.c b/gcc/convert.c index fbd18dee23e2..dc9f41f648af 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");