summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-06 15:32:38 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-06 15:32:38 +0000
commitbe2f725f9bfbe46b23cdd39f349bce6eb00f5b9c (patch)
treec828f6f61d900bf37c9c5909e2bd3852aef32c0a
parent85d7292bb7741cb3130fc5575e11b0170620e3d8 (diff)
downloadgcc-be2f725f9bfbe46b23cdd39f349bce6eb00f5b9c.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91778 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/java/ChangeLog8
-rw-r--r--gcc/java/check-init.c5
-rw-r--r--gcc/java/java-tree.h2
-rw-r--r--gcc/java/parse.y9
4 files changed, 19 insertions, 5 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 805c5e008b1..724403ab116 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-06 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-12-03 Tom Tromey <tromey@redhat.com>
* lang.c (flag_new_verifier): Define.
diff --git a/gcc/java/check-init.c b/gcc/java/check-init.c
index 05692b0a4c2..e124ffc5eef 100644
--- a/gcc/java/check-init.c
+++ b/gcc/java/check-init.c
@@ -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))
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 54cf01bbc0c..843e5f70098 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -1922,4 +1922,6 @@ extern tree build_expr_wfl PARAMS ((tree, const char *, int, int));
extern void java_genericize PARAMS ((tree));
extern int java_gimplify_expr PARAMS ((tree *, tree *, tree *));
+extern tree extract_field_decl (tree);
+
#endif /* ! GCC_JAVA_TREE_H */
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 2634de98f4f..815b51eae17 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -277,7 +277,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);
@@ -9678,12 +9677,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)
{
@@ -14260,7 +14259,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. */