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

Patch: PR java/10459


This fixes PR java/10459.

What happens here is that we can create an EXPR_WFL_NODE wrapping
NULL_TREE.  We avoid the crash by just checking for this situation.

The second test case will cause an ICE if the java_complete_lhs hunk
is removed -- a related bug.

Ok for the trunk?

This is a regression in 3.3.  I'd prefer to see it go in there as
well, since it fixes an ICE on legal code, and it is low-risk.

Tested on x86 Red Hat Linux 9 -- full rebuild of libgcj, plus test
suite including Mauve and Jacks.

Tom

Index: gcc/java/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	PR java/10459:
	* parse.y (finish_for_loop): Do nothing if update expression is a
	EXPR_WFL_NODE wrapping nothing.
	(java_complete_lhs) <COMPOUND_EXPR>: Likewise.

Index: gcc/java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.429
diff -u -r1.429 parse.y
--- gcc/java/parse.y 13 Apr 2003 01:45:34 -0000 1.429
+++ gcc/java/parse.y 2 May 2003 04:55:34 -0000
@@ -11771,7 +11771,9 @@
 	      nn = wfl_op2;
 	      if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
 		nn = EXPR_WFL_NODE (nn);
-	      if (TREE_CODE (nn) != EXIT_EXPR)
+	      /* NN can be NULL_TREE exactly when UPDATE is, in
+		 finish_for_loop.  */
+	      if (nn != NULL_TREE && TREE_CODE (nn) != EXIT_EXPR)
 		{
 		  SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
 		  if (SUPPRESS_UNREACHABLE_ERROR (nn))
@@ -14928,12 +14930,17 @@
       tree up2 = update;
       if (TREE_CODE (up2) == EXPR_WITH_FILE_LOCATION)
 	up2 = EXPR_WFL_NODE (up2);
-      /* Try to detect constraint violations.  These would be
-	 programming errors somewhere.  */
-      if (! IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (up2)))
-	  || TREE_CODE (up2) == LOOP_EXPR)
-	abort ();
-      SUPPRESS_UNREACHABLE_ERROR (up2) = 1;
+      /* It is possible for the update expression to be an
+	 EXPR_WFL_NODE wrapping nothing.  */
+      if (up2 != NULL_TREE && up2 != empty_stmt_node)
+	{
+	  /* Try to detect constraint violations.  These would be
+	     programming errors somewhere.  */
+	  if (! IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (up2)))
+	      || TREE_CODE (up2) == LOOP_EXPR)
+	    abort ();
+	  SUPPRESS_UNREACHABLE_ERROR (up2) = 1;
+	}
     }
   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
   return loop;
Index: libjava/testsuite/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	PR java/10459:
	* libjava.compile/pr10459_2.java: New file.
	* libjava.compile/pr10459.java: New file.

Index: libjava/testsuite/libjava.compile/pr10459.java
===================================================================
RCS file: libjava/testsuite/libjava.compile/pr10459.java
diff -N libjava/testsuite/libjava.compile/pr10459.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.compile/pr10459.java 2 May 2003 04:55:38 -0000
@@ -0,0 +1,10 @@
+public class pr10459
+{
+  pr10459 x;
+
+  public void aMethod() throws Throwable
+  {
+    for (; ;x.clone().clone())
+      ;
+  }
+}
Index: libjava/testsuite/libjava.compile/pr10459_2.java
===================================================================
RCS file: libjava/testsuite/libjava.compile/pr10459_2.java
diff -N libjava/testsuite/libjava.compile/pr10459_2.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.compile/pr10459_2.java 2 May 2003 04:55:38 -0000
@@ -0,0 +1,10 @@
+public class pr10459_2
+{
+  pr10459_2 x;
+
+  public void aMethod() throws Throwable
+  {
+    for (; ;x.clone().clone())
+      break;
+  }
+}


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