diff options
author | Tom Tromey <tromey@redhat.com> | 2005-06-03 04:06:19 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-06-03 04:06:19 +0000 |
commit | 4267db98773b84dd48f9bcc3b5b03dba6cbb9494 (patch) | |
tree | 7b45e87b69d880417f426174ec0944cdb7ac49a2 /gcc/java/class.c | |
parent | 50e5241d1f27fa5ce2919c3b9ef681bc3b2d24b3 (diff) | |
download | gcc-4267db98773b84dd48f9bcc3b5b03dba6cbb9494.zip gcc-4267db98773b84dd48f9bcc3b5b03dba6cbb9494.tar.gz gcc-4267db98773b84dd48f9bcc3b5b03dba6cbb9494.tar.bz2 |
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
Diffstat (limited to 'gcc/java/class.c')
-rw-r--r-- | gcc/java/class.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/gcc/java/class.c b/gcc/java/class.c index 88ca1f4..68732b7 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -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; |