This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: RFA: fix for PR java/17380
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>,Andrew Haley <aph at redhat dot com>
- Date: 22 Sep 2004 18:26:29 -0600
- Subject: Patch: RFA: fix for PR java/17380
- Reply-to: tromey at redhat dot com
This fixes PR java/17380.
The setup for this bug is sort of complicated, but basically it boils
down to the fact that an inner class is permitted to access a
protected member which its outer class inherited from some superclass.
gcj got this wrong because it used PURE_INNER_CLASS_TYPE_P, which also
checks to make sure the class is not static. This access check does
not depend on the static-ness of the class, so using
INNER_CLASS_TYPE_P is more appropriate.
This bug fix reveals a couple of latent bugs in our handling of
interface members. These are rather pedantic; I took the easy route
of simply XFAILing them.
In particular, this code from Jacks is supposed to fail:
interface T92i6 extends Cloneable {
class Inner {
Object bar(T92i6 i) {
try {
// Because this call is nested in the interface, it would have
// full access to protected i.clone() if that existed.
return i.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
}
}
We were rejecting this code by accident in not_accessible_p(), whereas
in reality we ought to reject it because Inner does not technically
inherit from Object.
Perhaps we could fix this in create_interface() by not setting the
superclass for an interface, but I suspect that will have other
ramifications (since an interface does inherit some method
declarations from Object), and I didn't want to get into it.
Tested on x86 FC2 including Mauve and Jacks. No regressions except
those mentioned.
Ok?
Tom
Index: libjava/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/17380:
* testsuite/libjava.jacks/jacks.xfail: Added 9.2-implicit-6 and
9.2-implicit-7.
Index: gcc/java/ChangeLog
from Tom Tromey <tromey@redhat.com>
PR java/17380:
* parse.y (not_accessible_p): Allow access to protected members
even when class is not static.
Index: gcc/java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.506
diff -u -r1.506 parse.y
--- gcc/java/parse.y 22 Sep 2004 10:51:42 -0000 1.506
+++ gcc/java/parse.y 23 Sep 2004 00:12:17 -0000
@@ -10065,7 +10074,7 @@
{
if (inherits_from_p (where, reference))
return 0;
- if (PURE_INNER_CLASS_TYPE_P (reference))
+ if (INNER_CLASS_TYPE_P (reference))
reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
else
break;
@@ -10079,7 +10088,7 @@
{
if (inherits_from_p (reference, DECL_CONTEXT (member)))
return 0;
- if (PURE_INNER_CLASS_TYPE_P (reference))
+ if (INNER_CLASS_TYPE_P (reference))
reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
else
break;
Index: libjava/testsuite/libjava.jacks/jacks.xfail
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.jacks/jacks.xfail,v
retrieving revision 1.17
diff -u -r1.17 jacks.xfail
--- libjava/testsuite/libjava.jacks/jacks.xfail 16 Aug 2004 23:57:30 -0000 1.17
+++ libjava/testsuite/libjava.jacks/jacks.xfail 23 Sep 2004 00:12:17 -0000
@@ -686,6 +686,8 @@
9.2-implicit-19
9.2-implicit-2
9.2-implicit-3
+9.2-implicit-6
+9.2-implicit-7
9.3.1-illegal-forward-1
9.3.1-illegal-forward-2
9.3.1-init-1