This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: another gcj assume-compiled fix


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.

The appended patch fixes this by adding the appropriate conditions to
the check.

Ok for trunk?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* class.c (build_static_field_ref): Only a String or numeric field
	can fold to a constant.

Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.150
diff -u -r1.150 class.c
--- class.c 22 Jan 2003 20:51:55 -0000 1.150
+++ class.c 23 Jan 2003 23:22:43 -0000
@@ -923,7 +924,11 @@
   int is_compiled = is_compiled_class (fclass);
 
   /* Allow static final fields to fold to a constant.  */
-  if (is_compiled || FIELD_FINAL (fdecl))
+  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))
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]