This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Java: Fix PR java/6085
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 10 Apr 2002 18:35:21 +1200
- Subject: Java: Fix PR java/6085
This patch fixes PR 6085. The problem is that build_access_to_thisn was
being called with the wrong arguments. This was being masked because it
wasn't being called at all in some cases, but the 6085 test case exposed
the problem.
Rebuild libjava and ran libjava testsuite with 0 failures (x86 linux).
OK to commit to mainline/branch?
regards
Bryce.
2002-04-10 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
Fix for PR java/6085:
* parse.y (patch_method_invocation): Always use build_access_to_thisn
to get extra enclosing "this" argument for constructor invocation. Pass
correct arguments to build_access_to_thisn.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.371
diff -u -r1.371 parse.y
--- parse.y 8 Apr 2002 06:41:36 -0000 1.371
+++ parse.y 10 Apr 2002 06:17:36 -0000
@@ -105,7 +105,6 @@
static int check_pkg_class_access PARAMS ((tree, tree, bool));
static void register_package PARAMS ((tree));
static tree resolve_package PARAMS ((tree, tree *, tree *));
-static tree lookup_package_type PARAMS ((const char *, int));
static tree resolve_class PARAMS ((tree, tree, tree, tree));
static void declare_local_variables PARAMS ((int, tree, tree));
static void dump_java_tree PARAMS ((enum tree_dump_index, tree));
@@ -10466,27 +10465,15 @@
/* This handles the situation where a constructor invocation needs
to have an enclosing context passed as a second parameter (the
- constructor is one of an inner class. We extract it from the
- current function. */
+ constructor is one of an inner class). */
if ((is_super_init ||
(TREE_CODE (patch) == CALL_EXPR && name == this_identifier_node))
&& PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
{
- tree enclosing_decl = DECL_CONTEXT (TYPE_NAME (current_class));
- tree extra_arg;
-
- if (ANONYMOUS_CLASS_P (current_class) || !DECL_CONTEXT (enclosing_decl))
- {
- extra_arg = DECL_FUNCTION_BODY (current_function_decl);
- extra_arg = TREE_CHAIN (BLOCK_EXPR_DECLS (extra_arg));
- }
- else
- {
- tree dest = TREE_TYPE (DECL_CONTEXT (enclosing_decl));
- extra_arg =
- build_access_to_thisn (TREE_TYPE (enclosing_decl), dest, 0);
- extra_arg = java_complete_tree (extra_arg);
- }
+ tree dest = TYPE_NAME (DECL_CONTEXT (list));
+ tree extra_arg =
+ build_access_to_thisn (current_class, DECL_CONTEXT (dest), 0);
+ extra_arg = java_complete_tree (extra_arg);
args = tree_cons (NULL_TREE, extra_arg, args);
}