aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@waitaki.otago.ac.nz>2002-03-16 20:57:10 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2002-03-16 20:57:10 +0000
commit568d1435c5e359df59f0a5b7ffc25f4178c5b781 (patch)
tree581a94803ebebec7ba9ff8a591be8dc0d905fc8f
parent5dd236e238bbea08ee2134d00306e03befd7e25b (diff)
downloadgcc-568d1435c5e359df59f0a5b7ffc25f4178c5b781.zip
gcc-568d1435c5e359df59f0a5b7ffc25f4178c5b781.tar.gz
gcc-568d1435c5e359df59f0a5b7ffc25f4178c5b781.tar.bz2
re PR java/5935 (problem with anonymous inner classes)
* parse.y (craft_constructor): Return the constructor decl. (java_expand_classes): Update comments. (lookup_method_invoke): Call fix_constructors immediately for anonymous class. Fixes PR java/5935. From-SVN: r50891
-rw-r--r--gcc/java/ChangeLog7
-rw-r--r--gcc/java/parse.y22
2 files changed, 23 insertions, 6 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 3f7b603..ce82f8d 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,10 @@
+2002-03-16 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
+
+ * parse.y (craft_constructor): Return the constructor decl.
+ (java_expand_classes): Update comments.
+ (lookup_method_invoke): Call fix_constructors immediately for
+ anonymous class. Fixes PR java/5935.
+
2002-03-15 Anthony Green <green@redhat.com>
* jcf-parse.c (yyparse): Don't emit class registration
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 953d075..6c39ad1 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -243,7 +243,7 @@ static tree build_instinit_invocation PARAMS ((tree));
static void fix_constructors PARAMS ((tree));
static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
tree, int *));
-static void craft_constructor PARAMS ((tree, tree));
+static tree craft_constructor PARAMS ((tree, tree));
static int verify_constructor_super PARAMS ((tree));
static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
static void start_artificial_method_body PARAMS ((tree));
@@ -5400,7 +5400,7 @@ build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
where found. ARGS is non NULL when a special signature must be
enforced. This is the case for anonymous classes. */
-static void
+static tree
craft_constructor (class_decl, args)
tree class_decl, args;
{
@@ -5449,6 +5449,7 @@ craft_constructor (class_decl, args)
/* Now, mark the artificial parameters. */
DECL_FUNCTION_NAP (decl) = artificial;
DECL_FUNCTION_SYNTHETIC_CTOR (decl) = DECL_CONSTRUCTOR_P (decl) = 1;
+ return decl;
}
@@ -8999,8 +9000,10 @@ java_expand_classes ()
}
input_filename = main_input_filename;
- /* Find anonymous classes and expand their constructor, now they
- have been fixed. */
+
+ /* Find anonymous classes and expand their constructor. This extra pass is
+ neccessary because the constructor itself is only generated when the
+ method in which it is defined is expanded. */
for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
{
tree current;
@@ -9018,7 +9021,7 @@ java_expand_classes ()
restore_line_number_status (1);
java_complete_expand_method (d);
restore_line_number_status (0);
- break; /* We now there are no other ones */
+ break; /* There is only one constructor. */
}
}
}
@@ -10855,7 +10858,14 @@ lookup_method_invoke (lc, cl, class, name, arg_list)
know the arguments' types. */
if (lc && ANONYMOUS_CLASS_P (class))
- craft_constructor (TYPE_NAME (class), atl);
+ {
+ tree saved_current_class;
+ tree mdecl = craft_constructor (TYPE_NAME (class), atl);
+ saved_current_class = current_class;
+ current_class = class;
+ fix_constructors (mdecl);
+ current_class = saved_current_class;
+ }
/* Find all candidates and then refine the list, searching for the
most specific method. */