]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR java/14853 (Assignment to final field permitted when compiling to native)
authorTom Tromey <tromey@redhat.com>
Wed, 8 Dec 2004 17:29:40 +0000 (17:29 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 8 Dec 2004 17:29:40 +0000 (17:29 +0000)
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.

From-SVN: r91910

gcc/java/ChangeLog
gcc/java/check-init.c
gcc/java/java-tree.h
gcc/java/parse.y

index 59fa5b733deaac04d5d873c03cad8019bfbf389f..a248524a748d87a87963e014e52c11c8ed007db6 100644 (file)
@@ -1,3 +1,11 @@
+2004-12-07  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.
+
 2004-11-04  Release Manager
 
        * GCC 3.4.3 released.
index c4e394844100835bcb87f9752f63d61cf947c0db..454aca5e19be134060ba317182b536626464c562 100644 (file)
@@ -164,6 +164,11 @@ static void check_final_reassigned (tree, words);
 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 22f41bd75233343627c8660df9a83f23fed3a8e7..64fb70a74402b747d662f46dc340feb0a5af38b0 100644 (file)
@@ -1801,4 +1801,7 @@ enum
 };
 
 #undef DEBUG_JAVA_BINDING_LEVELS
+
+extern tree extract_field_decl (tree);
+
 #endif /* ! GCC_JAVA_TREE_H */
index c0a88a1dbec57e013bcbcc265082c487dca048c0..047139412a9a22bf7de012373929cdc8499fe915 100644 (file)
@@ -259,7 +259,6 @@ static tree maybe_build_array_element_wfl (tree);
 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 @@ resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
   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 @@ patch_unaryop (tree node, tree wfl_op)
     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. */