diff mbox

[4.7,committed] : Fix PR c/51527

Message ID 4F9A7C0A.10301@gjlay.de
State New
Headers show

Commit Message

Georg-Johann Lay April 27, 2012, 10:59 a.m. UTC
http://gcc.gnu.org/viewcvs?view=revision&revision=186899

Applied as approved in
http://gcc.gnu.org/ml/gcc/2012-04/msg00843.html

Johann

	PR c/51527
	* convert.c (convert_to_integer): Avoid infinite recursion for
	target-defined built-in types.
diff mbox

Patch

Index: convert.c
===================================================================
--- convert.c	(revision 186872)
+++ convert.c	(working copy)
@@ -769,6 +769,7 @@  convert_to_integer (tree type, tree expr
 		   (Otherwise would recurse infinitely in convert.  */
 		if (TYPE_PRECISION (typex) != inprec)
 		  {
+		    tree otypex = typex;
 		    /* Don't do unsigned arithmetic where signed was wanted,
 		       or vice versa.
 		       Exception: if both of the original operands were
@@ -806,10 +807,12 @@  convert_to_integer (tree type, tree expr
 		      typex = unsigned_type_for (typex);
 		    else
 		      typex = signed_type_for (typex);
-		    return convert (type,
-				    fold_build2 (ex_form, typex,
-						 convert (typex, arg0),
-						 convert (typex, arg1)));
+
+		    if (TYPE_PRECISION (otypex) == TYPE_PRECISION (typex))
+		      return convert (type,
+				      fold_build2 (ex_form, typex,
+						   convert (typex, arg0),
+						   convert (typex, arg1)));
 		  }
 	      }
 	  }