From: Alexandre Petit-Bianco Date: Tue, 5 Dec 2000 07:08:56 +0000 (+0000) Subject: parse.y (patch_method_invocation): Pick the correct enclosing context when creating... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f8b93ea75d7fa70c34eca646c56ec34be2e13c00;p=gcc.git parse.y (patch_method_invocation): Pick the correct enclosing context when creating inner class instances. 2000-12-04 Alexandre Petit-Bianco * parse.y (patch_method_invocation): Pick the correct enclosing context when creating inner class instances. Fixes gcj/332. (http://gcc.gnu.org/ml/gcc-patches/2000-12/msg00217.html) From-SVN: r38026 --- diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 69e257bbcb3..69044f8506a 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2000-12-04 Alexandre Petit-Bianco + + * parse.y (patch_method_invocation): Pick the correct enclosing + context when creating inner class instances. + Fixes gcj/332. + 2000-11-26 Joseph S. Myers * gjavah.c (version), jcf-dump.c (version), jv-scan.c (version): diff --git a/gcc/java/parse.y b/gcc/java/parse.y index c411054b789..d89ace421cc 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -9997,7 +9997,33 @@ patch_method_invocation (patch, primary, where, is_static, ret_decl) /* Secretly pass the current_this/primary as a second argument */ if (primary || current_this) - args = tree_cons (NULL_TREE, (primary ? primary : current_this), args); + { + tree extra_arg; + tree this_type = (current_this ? + TREE_TYPE (TREE_TYPE (current_this)) : NULL_TREE); + /* Method's (list) enclosing context */ + tree mec = DECL_CONTEXT (TYPE_NAME (DECL_CONTEXT (list))); + /* If we have a primary, use it. */ + if (primary) + extra_arg = primary; + /* The current `this' is an inner class but isn't a direct + enclosing context for the inner class we're trying to + create. Build an access to the proper enclosing context + and use it. */ + else if (current_this && PURE_INNER_CLASS_TYPE_P (this_type) + && this_type != TREE_TYPE (mec)) + { + + extra_arg = build_access_to_thisn (current_class, + TREE_TYPE (mec), 0); + extra_arg = java_complete_tree (extra_arg); + } + /* Otherwise, just use the current `this' as an enclosing + context. */ + else + extra_arg = current_this; + args = tree_cons (NULL_TREE, extra_arg, args); + } else args = tree_cons (NULL_TREE, integer_zero_node, args); }