This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Java: Fix PR 16701
- From: Andrew Haley <aph at redhat dot com>
- To: Bryce McKinlay <mckinlay at redhat dot com>
- Cc: java-patches at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 2 Aug 2004 14:48:30 +0100
- Subject: Java: Fix PR 16701
- References: <41071425.9080702@redhat.com>
Bryce McKinlay writes:
> This patch fixes PR 16701. fold_constant_for_init() recursively resolves
> other constants, but it didn't update the global current_class before
> calling resolve_field_access(). This resulted in access checks being
> performed from the wrong context.
> Index: parse.y
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
> retrieving revision 1.496
> diff -u -r1.496 parse.y
> --- parse.y 26 Jul 2004 11:15:09 -0000 1.496
> +++ parse.y 28 Jul 2004 01:30:50 -0000
> @@ -15969,16 +15969,15 @@
> }
> else
> {
> - /* Install the proper context for the field resolution.
> - The prior context is restored once the name is
> - properly qualified. */
> + /* Install the proper context for the field resolution. */
> tree saved_current_class = current_class;
> /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
> current_class = DECL_CONTEXT (context);
> qualify_ambiguous_name (node);
> + resolve_field_access (node, &decl, NULL);
> + /* Restore prior context. */
> current_class = saved_current_class;
> - if (resolve_field_access (node, &decl, NULL)
> - && decl != NULL_TREE)
> + if (decl != NULL_TREE)
I think you need to check the return value of resolve_field_access().
If resolve_field_access() fails returning error_mark_node, no-one has
initialized decl.
Maybe I'm mistaken. Please check.
Andrew.