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: RFA: PR 14853 -vs- 3.4


This is the PR 14853 patch, back-ported to the 3.4 branch (the
java-tree.h part didn't apply cleanly, so the patch differences are
minimal).

This regression also affected 3.3 and 3.4, and one of the bugmasters
asked if I was going to back-port it.  So, I did it for 3.4.  I don't
plan to do it for 3.3 though.

Honestly I don't know how important this is.  We pretty much stopped
doing java work on 3.4 after it was released.  Nevertheless, here's
the patch.

Tested on x86 FC2.  Test case included.

Ok?

Tom

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

	PR java/14853:
	* java-tree.h (extract_field_decl): Declare.
	* parse.y (extract_field_decl): Renamed from
	strip_out_static_field_access_decl.  No longer static.
	* check-init.c (get_variable_decl): Unwrap COMPOUND_EXPRs.

Index: gcc/java/check-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/check-init.c,v
retrieving revision 1.53
diff -u -r1.53 check-init.c
--- gcc/java/check-init.c 28 Sep 2003 22:18:32 -0000 1.53
+++ gcc/java/check-init.c 8 Dec 2004 17:09:14 -0000
@@ -164,6 +164,11 @@
 static tree
 get_variable_decl (tree exp)
 {
+  /* A static field can be wrapped in a COMPOUND_EXPR where the first
+     argument initializes the class.  */
+  if (TREE_CODE (exp) == COMPOUND_EXPR)
+    exp = extract_field_decl (exp);
+
   if (TREE_CODE (exp) == VAR_DECL)
     {
       if (! TREE_STATIC (exp) ||  FIELD_FINAL (exp))
Index: gcc/java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.194
diff -u -r1.194 java-tree.h
--- gcc/java/java-tree.h 16 Jan 2004 17:11:08 -0000 1.194
+++ gcc/java/java-tree.h 8 Dec 2004 17:09:14 -0000
@@ -1801,4 +1801,7 @@
 };
 
 #undef DEBUG_JAVA_BINDING_LEVELS
+
+extern tree extract_field_decl (tree);
+
 #endif /* ! GCC_JAVA_TREE_H */
Index: gcc/java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.464.4.2
diff -u -r1.464.4.2 parse.y
--- gcc/java/parse.y 26 Feb 2004 14:12:19 -0000 1.464.4.2
+++ gcc/java/parse.y 8 Dec 2004 17:09:19 -0000
@@ -259,7 +259,6 @@
 static int array_constructor_check_entry (tree, tree);
 static const char *purify_type_name (const char *);
 static tree fold_constant_for_init (tree, tree);
-static tree strip_out_static_field_access_decl (tree);
 static jdeplist *reverse_jdep_list (struct parser_ctxt *);
 static void static_ref_err (tree, tree, tree);
 static void parser_add_interface (tree, tree, tree);
@@ -9512,12 +9511,12 @@
   return field_ref;
 }
 
-/* If NODE is an access to f static field, strip out the class
+/* If NODE is an access to a static field, strip out the class
    initialization part and return the field decl, otherwise, return
    NODE. */
 
-static tree
-strip_out_static_field_access_decl (tree node)
+tree
+extract_field_decl (tree node)
 {
   if (TREE_CODE (node) == COMPOUND_EXPR)
     {
@@ -14069,7 +14068,7 @@
     case PREINCREMENT_EXPR:
       /* 15.14.2 Prefix Decrement Operator -- */
     case PREDECREMENT_EXPR:
-      op = decl = strip_out_static_field_access_decl (op);
+      op = decl = extract_field_decl (op);
       outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
       /* We might be trying to change an outer field accessed using
          access method. */
Index: libjava/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	For PR java/14853:
	* testsuite/libjava.compile/PR14853.java: New file.
	* testsuite/libjava.compile/PR14853.xfail: New file.

Index: libjava/testsuite/libjava.compile/PR14853.java
===================================================================
RCS file: libjava/testsuite/libjava.compile/PR14853.java
diff -N libjava/testsuite/libjava.compile/PR14853.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.compile/PR14853.java 8 Dec 2004 17:09:26 -0000
@@ -0,0 +1,17 @@
+class tt
+{
+  static final tt tt1 = new tt();
+  tt()
+  {
+  }
+}
+
+public class PR14853
+{
+  public static void main (String[] args)
+  {
+    // This is an invalid assignment.  gcj would get confused in
+    // definite assignment when compiling to object code.
+    tt.tt1 = new tt();
+  }
+}
Index: libjava/testsuite/libjava.compile/PR14853.xfail
===================================================================
RCS file: libjava/testsuite/libjava.compile/PR14853.xfail
diff -N libjava/testsuite/libjava.compile/PR14853.xfail
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/testsuite/libjava.compile/PR14853.xfail 8 Dec 2004 17:09:26 -0000
@@ -0,0 +1 @@
+shouldfail


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