This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

convert_to_pointer vs partial_int modes

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
 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
 	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);
       error ("cannot convert to a pointer type");

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]