This is the mail archive of the gcc-patches@gcc.gnu.org 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]

[tuples] dereference POINTER_PLUS_EXPR check


Hi Diego.

Many fortran testcases are failing in verify_types_in_gimple_assign()
because, in a GIMPLE_ASSIGN, a POINTER_PLUS_EXPR can be embeddeded in
an assignment.  However, when verifying type validity, we no longer
have the type of the POINTER_PLUS_EXPR.  In the absence of this type, we
must look at the pointed-to type to determine type compatability.

This patch drills down to the dereferenced type.

With this patch, we have no ICEs that are not already present on
mainline while checking fortran.

Is this OK for the tuples branch?

Aldy

	* tree-cfg.c (verify_types_in_gimple_assign): Use the dereferenced
	type when checking the validity of a POINTER_PLUS_EXPR.

Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 130313)
+++ tree-cfg.c	(working copy)
@@ -3558,16 +3558,37 @@ verify_types_in_gimple_assign (gimple st
 	    error ("invalid operands in pointer plus expression");
 	    return true;
 	  }
-	if (!POINTER_TYPE_P (rhs1_type)
-	    || !useless_type_conversion_p (lhs_type, rhs1_type)
+
+	if (!POINTER_TYPE_P (lhs_type)
+	    || !POINTER_TYPE_P (rhs1_type))
+	  {
+	    error ("type mismatch in pointer plus expression");
+	    return true;
+	  }
+
+	/* Drill down to get to the pointed-to type.  */
+	{
+	  tree lhs_type_orig = lhs_type;
+	  tree rhs1_type_orig = rhs1_type;
+
+	  while (POINTER_TYPE_P (rhs1_type)
+		 || TREE_CODE (rhs1_type) == ARRAY_TYPE)
+	    rhs1_type = TREE_TYPE (rhs1_type);
+
+	  while (POINTER_TYPE_P (lhs_type)
+		 || TREE_CODE (lhs_type) == ARRAY_TYPE)
+	    lhs_type = TREE_TYPE (lhs_type);
+
+	if (!useless_type_conversion_p (lhs_type, rhs1_type)
 	    || !useless_type_conversion_p (sizetype, rhs2_type))
 	  {
 	    error ("type mismatch in pointer plus expression");
-	    debug_generic_stmt (lhs_type);
-	    debug_generic_stmt (rhs1_type);
+	    debug_generic_stmt (lhs_type_orig);
+	    debug_generic_stmt (rhs1_type_orig);
 	    debug_generic_stmt (rhs2_type);
 	    return true;
 	  }
+	}
 
 	return false;
       } 


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