Patchwork GIMPLE verification of pointer-int conversions (PR52443)

login
register
mail settings
Submitter Richard Guenther
Date March 1, 2012, 10:50 a.m.
Message ID <alpine.LNX.2.00.1203011147570.18230@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/143986/
State New
Headers show

Comments

Richard Guenther - March 1, 2012, 10:50 a.m.
This should fix PR52443 - it is not necessary to restrict integer to
pointer conversions.  We do restrict pointer to integer conversions
because of the unknown signedness of pointers.  There is no reason
to do the same for integer to pointer conversions.

Bootstrap and regtest on x86_64-unknown-linux-gnu running, but there
is only strictly more cases that now return "OK GIMPLE" - so I consider
this for trunk at this stage.

Richard.

2012-03-01  Richard Guenther  <rguenther@suse.de>

	PR middle-end/52443
	* tree-cfg.c (verify_gimple_assign_unary): Allow any
	conversions from integral types to pointer types.

Patch

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 184688)
+++ gcc/tree-cfg.c	(working copy)
@@ -3340,15 +3429,12 @@  verify_gimple_assign_unary (gimple stmt)
     {
     CASE_CONVERT:
       {
-	/* Allow conversions between integral types and pointers only if
+	/* Allow conversions pointer type to integral type only if
 	   there is no sign or zero extension involved.
 	   For targets were the precision of ptrofftype doesn't match that
-	   of pointers we need to allow arbitrary conversions from and
-	   to ptrofftype.  */
+	   of pointers we need to allow arbitrary conversions to ptrofftype.  */
 	if ((POINTER_TYPE_P (lhs_type)
-	     && INTEGRAL_TYPE_P (rhs1_type)
-	     && (TYPE_PRECISION (lhs_type) >= TYPE_PRECISION (rhs1_type)
-		 || ptrofftype_p (rhs1_type)))
+	     && INTEGRAL_TYPE_P (rhs1_type))
 	    || (POINTER_TYPE_P (rhs1_type)
 		&& INTEGRAL_TYPE_P (lhs_type)
 		&& (TYPE_PRECISION (rhs1_type) >= TYPE_PRECISION (lhs_type)