public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [tuples] dereference POINTER_PLUS_EXPR check
@ 2007-11-21 22:03 Aldy Hernandez
  2007-11-21 23:03 ` Diego Novillo
  2007-11-21 23:31 ` Richard Guenther
  0 siblings, 2 replies; 24+ messages in thread
From: Aldy Hernandez @ 2007-11-21 22:03 UTC (permalink / raw)
  To: dnovillo, gcc-patches

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;
       } 

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2007-11-28 17:45 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-21 22:03 [tuples] dereference POINTER_PLUS_EXPR check Aldy Hernandez
2007-11-21 23:03 ` Diego Novillo
2007-11-21 23:25   ` Aldy Hernandez
2007-11-21 23:43     ` Richard Guenther
2007-11-22  1:26       ` Aldy Hernandez
2007-11-22  7:35         ` Richard Guenther
2007-11-22 11:32           ` Aldy Hernandez
2007-11-22 12:08             ` Andrew Pinski
2007-11-22 21:35               ` [FORTRAN mainline] dereference POINTER_PLUS_EXPR check (was tuples) Aldy Hernandez
2007-11-22 21:56                 ` Richard Guenther
2007-11-23 11:38                   ` Aldy Hernandez
2007-11-23 12:13                     ` Richard Guenther
2007-11-24 20:54                     ` libgomp failure (was: Re: [FORTRAN mainline] dereference POINTER_PLUS_EXPR check) Tobias Burnus
2007-11-25 16:13                       ` Aldy Hernandez
2007-11-25 21:32                       ` Aldy Hernandez
2007-11-25 21:59                         ` Richard Guenther
2007-11-27 13:24                         ` [PATCH] Fix fortran libgomp failures Jakub Jelinek
2007-11-27 16:51                           ` Richard Guenther
2007-11-28 19:39                             ` Tobias Burnus
2007-11-22 22:09                 ` [FORTRAN mainline] dereference POINTER_PLUS_EXPR check (was tuples) Tobias Burnus
2007-11-22 13:43             ` [tuples] dereference POINTER_PLUS_EXPR check Richard Guenther
2007-11-22 15:34           ` Diego Novillo
2007-11-22 18:56             ` Aldy Hernandez
2007-11-21 23:31 ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).