re PR java/21722 (gcj miscompiles accesses to static final vars with indirect dispatch)

PR java/21722:
	* class.c (build_static_field_ref): Don't fold constant fields if
	current class is from a .class file and we're using indirect
	dispatch.

From-SVN: r100533
This commit is contained in:
Tom Tromey 2005-06-03 04:06:19 +00:00 committed by Tom Tromey
parent 50e5241d1f
commit 4267db9877
2 changed files with 17 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2005-06-01 Tom Tromey <tromey@redhat.com>
PR java/21722:
* class.c (build_static_field_ref): Don't fold constant fields if
current class is from a .class file and we're using indirect
dispatch.
2005-05-31 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* java/verify-glue.c: Don't include errors.h and include toplev.h.

View File

@ -1068,19 +1068,18 @@ build_static_field_ref (tree fdecl)
{
tree fclass = DECL_CONTEXT (fdecl);
int is_compiled = is_compiled_class (fclass);
int from_class = ! CLASS_FROM_SOURCE_P (current_class);
/* Allow static final fields to fold to a constant. When using
-fno-assume-compiled, gcj will sometimes try to fold a field from
an uncompiled class. This is required when the field in question
meets the appropriate criteria for a compile-time constant.
However, currently sometimes gcj is too eager and will end up
returning the field itself, leading to an incorrect external
reference being generated. */
if ((is_compiled && !flag_indirect_dispatch)
|| (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE
&& (JSTRING_TYPE_P (TREE_TYPE (fdecl))
|| JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
&& TREE_CONSTANT (DECL_INITIAL (fdecl))))
-findirect-dispatch, we simply never do this folding if compiling
from .class; in the .class file constants will be referred to via
the constant pool. */
if ((!flag_indirect_dispatch || !from_class)
&& (is_compiled
|| (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE
&& (JSTRING_TYPE_P (TREE_TYPE (fdecl))
|| JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
&& TREE_CONSTANT (DECL_INITIAL (fdecl)))))
{
if (is_compiled == 1)
DECL_EXTERNAL (fdecl) = 1;