This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
PATCH to maybe_yank_clinit
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Subject: PATCH to maybe_yank_clinit
- From: Per Bothner <per at bothner dot com>
- Date: Sat, 1 Sep 2001 15:03:11 -0700
After my most recent checkins, some tests fail because <clinit> was
elided. I looked at maybe_yank_clinit and it did some strange things
I don't understand, so I tried the following patch, which seems better.
Alex, do you know why the old code was as it was? Do can you think of
a problem with my patch?
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.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.306
diff -u -p -r1.306 parse.y
--- parse.y 2001/09/01 04:42:50 1.306
+++ parse.y 2001/09/01 21:55:01
@@ -7862,25 +7862,21 @@ 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
correctly. */
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;
}
--Per Bothner
per@bothner.com http://www.bothner.com/per/