diff options
author | Per Bothner <per@bothner.com> | 2001-09-04 14:50:31 -0700 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 2001-09-04 14:50:31 -0700 |
commit | 0286a91d403c41cc555b534afa9bc37aa1f657c8 (patch) | |
tree | 3aa4d589e9f930024d5f2e721aeee96095bdd21b /gcc | |
parent | c0dae541cf5963c517c121a0f6b4b0886578d216 (diff) | |
download | gcc-0286a91d403c41cc555b534afa9bc37aa1f657c8.zip gcc-0286a91d403c41cc555b534afa9bc37aa1f657c8.tar.gz gcc-0286a91d403c41cc555b534afa9bc37aa1f657c8.tar.bz2 |
parse.y (maybe_yank_clinit): A field without an initializer is not relevant.
* parse.y (maybe_yank_clinit): A field without an initializer is not
relevant. All initializers except static final and constant require
<clinit>, regardless of flag_emit_class_files.
From-SVN: r45388
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/java/parse.y | 20 |
2 files changed, 14 insertions, 12 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 3a92114..0f19738 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2001-09-01 Per Bothner <per@bothner.com> + + * parse.y (maybe_yank_clinit): A field without an initializer is not + relevant. All initializers except static final and constant require + <clinit>, regardless of flag_emit_class_files. + 2001-08-31 Per Bothner <per@bothner.com> * class.c (set_constant_value): When not emiting class files, then a diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 09a4dcd..698f4227 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -7862,6 +7862,12 @@ maybe_yank_clinit (mdecl) if (!FIELD_STATIC (current)) continue; + /* nor in fields with initializers. */ + f_init = DECL_INITIAL (current); + + if (f_init == NULL_TREE) + continue; + /* Anything that isn't String or a basic type is ruled out -- or if we know how to deal with it (when doing things natively) we should generated an empty <clinit> so that SUID are computed @@ -7869,18 +7875,8 @@ maybe_yank_clinit (mdecl) if (! JSTRING_TYPE_P (TREE_TYPE (current)) && ! JNUMERIC_TYPE_P (TREE_TYPE (current))) break; - - f_init = DECL_INITIAL (current); - /* If we're emitting native code, we want static final fields to - have constant initializers. If we don't meet these - conditions, we keep <clinit> */ - if (!flag_emit_class_files - && !(FIELD_FINAL (current) && f_init && TREE_CONSTANT (f_init))) - break; - /* If we're emitting bytecode, we want static fields to have - constant initializers or no initializer. If we don't meet - these conditions, we keep <clinit> */ - if (flag_emit_class_files && f_init && !TREE_CONSTANT (f_init)) + + if (! FIELD_FINAL (current) || ! TREE_CONSTANT (f_init)) break; } |