convert_to_pointer vs partial_int modes
DJ Delorie
dj@redhat.com
Sat May 28 03:13:00 GMT 2005
One last invalid assumption tonight. When pointers happen to be
partial_ints, sometimes the lang_hook chooses to do nothing to convert
it. In that case, this patch avoids infinite recursion.
* convert.c (convert_to_pointer): Avoid recursion if no
conversion is needed.
Index: convert.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/convert.c,v
retrieving revision 1.63
diff -p -U3 -r1.63 convert.c
--- convert.c 26 May 2005 04:38:51 -0000 1.63
+++ convert.c 28 May 2005 03:05:51 -0000
@@ -41,6 +41,8 @@ Software Foundation, 59 Temple Place - S
tree
convert_to_pointer (tree type, tree expr)
{
+ tree newexpr;
+
if (integer_zerop (expr))
{
expr = build_int_cst (type, 0);
@@ -60,10 +62,11 @@ convert_to_pointer (tree type, tree expr
if (TYPE_PRECISION (TREE_TYPE (expr)) == POINTER_SIZE)
return build1 (CONVERT_EXPR, type, expr);
- return
- convert_to_pointer (type,
- convert (lang_hooks.types.type_for_size
- (POINTER_SIZE, 0), expr));
+ newexpr = convert (lang_hooks.types.type_for_size
+ (POINTER_SIZE, 0), expr);
+ if (newexpr == expr)
+ return expr;
+ return convert_to_pointer (type, newexpr);
default:
error ("cannot convert to a pointer type");
More information about the Gcc-patches
mailing list