This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Java: Remove set_nested_class_simple_name_value()
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 23 Jun 2004 22:50:25 -0400
- Subject: Java: Remove set_nested_class_simple_name_value()
This patch fixes a bug that is exposed by another patch I'm working on,
but the underlying problem is present on the current mainline compiler.
What happens is:
1. GCJ parses Arrays.java, and set_nested_class_simple_name_value is
called to set IDENTIFIER_CLASS_VALUE on indentifier nodes for each of
its inner classes. IDENTIFIER_CLASS_VALUE for "ArrayList" is set to the
inner class Arrays$ArrayList.
2. Then, while expanding methods in the Arrays class, a reference to the
Collections class is seen and gcj recursively parses Collections.java.
Collections has a reference to a type called "ArrayList". When
do_resolve_class() is called, IDENTIFIER_CLASS_VALUE of "ArrayList"
erronously obtains Arrays$ArrayList.
This sequence of events is sensitive to the order of files being parsed,
whether or not they exist as classfiles, etc, but suffice to say that
when other checks are improved, this bug is seen when compiling libjava.
As far as I can tell, set_nested_class_simple_name_value does nothing
useful and is quite broken given the recursive nature of gcj's class
resolution and expansion. This patch removes it.
No testsuite regressions - ok to commit?
Bryce
2004-06-23 Bryce McKinlay <mckinlay@redhat.com>
* parse.y (set_nested_class_simple_name_value): Removed.
(java_complete_expand_class): Remove calls to
set_nested_class_simple_name_value.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.483
diff -u -r1.483 parse.y
--- parse.y 22 Jun 2004 18:17:12 -0000 1.483
+++ parse.y 24 Jun 2004 02:49:16 -0000
@@ -296,7 +296,6 @@
static tree maybe_make_nested_class_name (tree);
static int make_nested_class_name (tree);
-static void set_nested_class_simple_name_value (tree, int);
static void link_nested_class_to_enclosing (void);
static tree resolve_inner_class (htab_t, tree, tree *, tree *, tree);
static tree find_as_inner_class (tree, tree, tree);
@@ -3694,19 +3693,6 @@
return (!qual && enclosing ? enclosing : NULL_TREE);
}
-/* Reach all inner classes and tie their unqualified name to a
- DECL. */
-
-static void
-set_nested_class_simple_name_value (tree outer, int set)
-{
- tree l;
-
- for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
- IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
- TREE_PURPOSE (l) : NULL_TREE);
-}
-
static void
link_nested_class_to_enclosing (void)
{
@@ -7712,8 +7698,6 @@
{
tree inner_list;
- set_nested_class_simple_name_value (outer, 1); /* Set */
-
/* We need to go after all inner classes and start expanding them,
starting with most nested ones. We have to do that because nested
classes might add functions to outer classes */
@@ -7723,7 +7707,6 @@
java_complete_expand_class (TREE_PURPOSE (inner_list));
java_complete_expand_methods (outer);
- set_nested_class_simple_name_value (outer, 0); /* Reset */
}
/* Expand methods registered in CLASS_DECL. The general idea is that