Commit 4267db98 by Tom Tromey Committed by Tom Tromey

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
parent 50e5241d
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> 2005-05-31 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* java/verify-glue.c: Don't include errors.h and include toplev.h. * java/verify-glue.c: Don't include errors.h and include toplev.h.
......
...@@ -1068,19 +1068,18 @@ build_static_field_ref (tree fdecl) ...@@ -1068,19 +1068,18 @@ build_static_field_ref (tree fdecl)
{ {
tree fclass = DECL_CONTEXT (fdecl); tree fclass = DECL_CONTEXT (fdecl);
int is_compiled = is_compiled_class (fclass); 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 /* Allow static final fields to fold to a constant. When using
-fno-assume-compiled, gcj will sometimes try to fold a field from -findirect-dispatch, we simply never do this folding if compiling
an uncompiled class. This is required when the field in question from .class; in the .class file constants will be referred to via
meets the appropriate criteria for a compile-time constant. the constant pool. */
However, currently sometimes gcj is too eager and will end up if ((!flag_indirect_dispatch || !from_class)
returning the field itself, leading to an incorrect external && (is_compiled
reference being generated. */ || (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE
if ((is_compiled && !flag_indirect_dispatch) && (JSTRING_TYPE_P (TREE_TYPE (fdecl))
|| (FIELD_FINAL (fdecl) && DECL_INITIAL (fdecl) != NULL_TREE || JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
&& (JSTRING_TYPE_P (TREE_TYPE (fdecl)) && TREE_CONSTANT (DECL_INITIAL (fdecl)))))
|| JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
&& TREE_CONSTANT (DECL_INITIAL (fdecl))))
{ {
if (is_compiled == 1) if (is_compiled == 1)
DECL_EXTERNAL (fdecl) = 1; DECL_EXTERNAL (fdecl) = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment