This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Java: Enable accessibility checks for static inner classes


Static inner classes are subject to the same member accessibility checks as regular inner classes, however gcj is currently not calling check_nested_class_access() for static inner classes. This patch also fixes a bug that was exposed by enabling this check: JDEP_ENCLOSING (the context from which the access is being attempted - should really be called JDEP_CONTEXT ??) was being set to NULL_TREE for a top level class extending a static inner class. The fix is to make "extends" behave the same as "implements" and anonymous inner class dependencies.

No testsuite regressions, and a Jacks XPASS for 8.1.3-superclass-6.

OK to commit?

Bryce

2004-06-26  Bryce McKinlay  <mckinlay@redhat.com>

	* parse.y (register_incomplete_type): Set JDEP_ENCLOSING for "super"
	dependency to current parser context, not NULL_TREE, for top-level
	classes.
	(jdep_resolve_class): Enable member access check for all inner
	class dependencies.

Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.484
diff -u -r1.484 parse.y
--- parse.y	24 Jun 2004 15:56:54 -0000	1.484
+++ parse.y	26 Jun 2004 00:23:43 -0000
@@ -5187,12 +5187,9 @@
   JDEP_MISC (new) = NULL_TREE;
   /* For some dependencies, set the enclosing class of the current
      class to be the enclosing context */
-  if ((kind == JDEP_INTERFACE  || kind == JDEP_ANONYMOUS)
+  if ((kind == JDEP_INTERFACE  || kind == JDEP_ANONYMOUS || kind == JDEP_SUPER)
       && GET_ENCLOSING_CPC ())
     JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
-  else if (kind == JDEP_SUPER)
-    JDEP_ENCLOSING (new) = (GET_ENCLOSING_CPC () ?
-			    TREE_VALUE (GET_ENCLOSING_CPC ()) : NULL_TREE);
   else
     JDEP_ENCLOSING (new) = GET_CPC ();
   JDEP_GET_PATCH (new) = (tree *)NULL;
@@ -5512,7 +5509,7 @@
 
   if (!decl)
     complete_class_report_errors (dep);
-  else if (PURE_INNER_CLASS_DECL_P (decl))
+  else if (INNER_CLASS_DECL_P (decl))
     {
       tree inner = TREE_TYPE (decl);
       if (! CLASS_LOADED_P (inner))

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