This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Java: fix to gcj/283, gcj/297
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH] Java: fix to gcj/283, gcj/297
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Tue, 21 Nov 2000 21:06:35 -0800
- Reply-to: apbianco at cygnus dot com
This patch fixes gcj/283 and gcj/297:
http://sources.redhat.com/ml/java-prs/2000-q3/msg00045.html
http://sources.redhat.com/ml/java-prs/2000-q3/msg00098.html
I'm checking this in as its in the way of people working on Collection
classes.
./A
2000-10-31 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (outer_field_access_p): Inherited fields aren't
consider outer fields.
(maybe_build_thisn_access_method): Use
PURE_INNER_CLASS_TYPE_P instead of INNER_CLASS_TYPE_P.
(resolve_expression_name): Trigger an error if a static field
is being accessed as an outer field.
2000-10-24 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.h (INNER_ENCLOSING_SCOPE_CHECK): Check inherited type in
scope.
Index: parse.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.h,v
retrieving revision 1.61
diff -u -p -r1.61 parse.h
--- parse.h 2000/10/21 15:10:38 1.61
+++ parse.h 2000/11/22 05:01:34
@@ -860,7 +860,12 @@ struct parser_ctxt {
&& !inherits_from_p (TREE_TYPE (TREE_TYPE (current_this)), \
TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T)))) \
&& !common_enclosing_context_p (TREE_TYPE (TREE_TYPE (current_this)), \
- (T))) \
+ (T)) \
+ && INNER_CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (current_this))) \
+ && !inherits_from_p \
+ (TREE_TYPE (DECL_CONTEXT \
+ (TYPE_NAME (TREE_TYPE (TREE_TYPE (current_this))))),\
+ TREE_TYPE (DECL_CONTEXT (TYPE_NAME (T))))) \
/* We don't have a this. */ \
|| !current_this))
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.228
diff -u -p -r1.228 parse.y
--- parse.y 2000/11/20 22:37:22 1.228
+++ parse.y 2000/11/22 05:01:34
@@ -7887,6 +7887,11 @@ outer_field_access_p (type, decl)
|| TREE_CODE (decl) != FIELD_DECL
|| DECL_CONTEXT (decl) == type)
return 0;
+
+ /* If the inner class extends the declaration context of the field
+ we're try to acces, then this isn't an outer field access */
+ if (inherits_from_p (type, DECL_CONTEXT (decl)))
+ return 0;
for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
@@ -8238,7 +8243,7 @@ maybe_build_thisn_access_method (type)
/* If TYPE is a top-level class, no access method is required.
If there already is such an access method, bail out. */
- if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
+ if (CLASS_ACCESS0_GENERATED_P (type) || !PURE_INNER_CLASS_TYPE_P (type))
return NULL_TREE;
/* We generate the method. The method looks like:
@@ -8866,7 +8871,14 @@ resolve_expression_name (id, orig)
to access a field belonging to an outer class, build
the access to the field */
if (!fs && outer_field_access_p (current_class, decl))
- return build_outer_field_access (id, decl);
+ {
+ if (CLASS_STATIC (TYPE_NAME (current_class)))
+ {
+ static_ref_err (id, DECL_NAME (decl), current_class);
+ return error_mark_node;
+ }
+ return build_outer_field_access (id, decl);
+ }
/* Otherwise build what it takes to access the field */
access = build_field_ref ((fs ? NULL_TREE : current_this),