diff options
author | Tom Tromey <tromey@redhat.com> | 2003-01-24 17:44:03 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-01-24 17:44:03 +0000 |
commit | c2c984456c2f949d91c8f514d99fd84bdd14113b (patch) | |
tree | 4721e77b27ce0835e2eb4e96ac083a7a72f02eb2 /gcc/java/class.c | |
parent | 38997f1bf5ea21dc05d978620d031da33083093d (diff) | |
download | gcc-c2c984456c2f949d91c8f514d99fd84bdd14113b.zip gcc-c2c984456c2f949d91c8f514d99fd84bdd14113b.tar.gz gcc-c2c984456c2f949d91c8f514d99fd84bdd14113b.tar.bz2 |
class.c (build_static_field_ref): Only a String or numeric field can fold to a constant.
* class.c (build_static_field_ref): Only a String or numeric field
can fold to a constant.
From-SVN: r61723
Diffstat (limited to 'gcc/java/class.c')
-rw-r--r-- | gcc/java/class.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/java/class.c b/gcc/java/class.c index d0953cc..dfaf6f1 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -922,8 +922,18 @@ build_static_field_ref (tree fdecl) tree fclass = DECL_CONTEXT (fdecl); int is_compiled = is_compiled_class (fclass); - /* Allow static final fields to fold to a constant. */ - if (is_compiled || FIELD_FINAL (fdecl)) + /* 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 + || (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 (!DECL_RTL_SET_P (fdecl)) { |