This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Java: PR gcj/242
- To: gcc-patches at gcc dot gnu dot org
- Subject: Java: PR gcj/242
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: Thu, 01 Jun 2000 00:01:29 +1200
This patch fixes the PR gcj/242:
http://sourceware.cygnus.com/ml/java-prs/2000-q2/msg00223.html
The problem is in maybe_use_access_method, which arranges for the
appropriate "this" argument to be passed to the target method in the
case where the method is declared in an enclosing context of the current
class. However, it does not consider that the method may have been
declared in a superclass of an enclosing context, and so fails to set
"this" in that case.
By the way, isn't it a bit unintuitive to call the method decl "list" in
patch_method_invocation? Wouldn't "mdecl" be clearer?
regards
[ bryce ]
2000-05-31 Bryce McKinlay <bryce@albatross.co.nz>
* parse.y (patch_method_invocation): Add comment.
(maybe_use_access_method): Check to see if method was declared in a
superclass of an enclosing class. Fix for PR gcj/242.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/parse.y,v
retrieving revision 1.171
diff -u -r1.171 parse.y
--- parse.y 2000/05/26 18:57:28 1.171
+++ parse.y 2000/05/31 06:23:59
@@ -9458,6 +9458,8 @@
args = nreverse (args);
if (TREE_CODE (patch) != NEW_CLASS_EXPR)
{
+ /* If LIST was found in an enclosing context, maybe_use_access_method
+ will re-set this_arg to the appropriate value. */
this_arg = primary ? primary : current_this;
/* If we're using an access method, things are different.
@@ -9627,7 +9629,7 @@
if (non_static_context)
{
ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
- if (ctx == DECL_CONTEXT (md))
+ if (inherits_from_p (ctx, DECL_CONTEXT (md)))
{
ta = build_current_thisn (current_class);
ta = build_wfl_node (ta);
@@ -9638,7 +9640,7 @@
while (type)
{
maybe_build_thisn_access_method (type);
- if (type == DECL_CONTEXT (md))
+ if (inherits_from_p (ctx, DECL_CONTEXT (md)))
{
ta = build_access_to_thisn (ctx, type, 0);
break;