Patch: RFA: fix PR java/17329
Tom Tromey
tromey@redhat.com
Wed Sep 22 19:06:00 GMT 2004
In PR 17329, we are compiling code like this, where Options is a
different class:
Options.verbose += 2;
This results in a save_expr the _Jv_InitClass call; there is special
code in gimplify_save_expr() to handle this (searching for "java" in
this file was enlightening, I had no idea about all these special
cases).
Anyway, gimplify_save_expr will set the save_expr argument to NULL the
first time it is seen, but java_gimplify_expr doesn't account for this
case and crashes.
I think the proper thing to do is to ignore the save_expr if its
argument is NULL.
Tested on x86 FC2, including mauve and jacks; rebuilt libgcj from
scratch as well. Regression test included.
Ok?
Tom
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/17329:
* java-gimplify.c (java_gimplify_expr) <SAVE_EXPR>: Ignore case
where operand is null.
Index: gcc/java/java-gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-gimplify.c,v
retrieving revision 1.14
diff -u -r1.14 java-gimplify.c
--- gcc/java/java-gimplify.c 17 Sep 2004 21:54:58 -0000 1.14
+++ gcc/java/java-gimplify.c 22 Sep 2004 02:09:05 -0000
@@ -108,7 +108,10 @@
return GS_UNHANDLED;
case SAVE_EXPR:
- if (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == VAR_DECL)
+ /* Note that we can see <save_expr NULL> if the save_expr was
+ already handled by gimplify_save_expr. */
+ if (TREE_OPERAND (*expr_p, 0) != NULL_TREE
+ && TREE_CODE (TREE_OPERAND (*expr_p, 0)) == VAR_DECL)
TREE_OPERAND (*expr_p, 0)
= java_replace_reference (TREE_OPERAND (*expr_p, 0),
/* want_lvalue */ false);
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/17329:
* testsuite/libjava.compile/pr17329.java: New file.
Index: libjava/testsuite/libjava.compile/pr17329.java
===================================================================
RCS file: libjava/testsuite/libjava.compile/pr17329.java
diff -N libjava/testsuite/libjava.compile/pr17329.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.compile/pr17329.java 22 Sep 2004 02:09:14 -0000
@@ -0,0 +1,14 @@
+// gcj had a problem with "SomeClass.field++" when gimplifying.
+
+class helper
+{
+ static int value;
+}
+
+public class pr17329
+{
+ static void doit ()
+ {
+ helper.value += 2;
+ }
+}
More information about the Java-patches
mailing list