This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: FYI: PR 28754


I'm checking this in on the trunk.

In PR 28754, a test program SEGVs because we don't initialize a
field's declaring interface.  This happens because ecj generates a
reference to the correct qualifying class, and with the C++ ABI there
is nothing else to cause the interface to be initialized.

This patch changes gcj to emit an explicit initialization for the
actually declaring class as well.  Note that we don't need to do this
for the BC ABI case, as that is properly handled by the runtime.

There is a slightly different patch on the ecj branch for this
problem.  I had forgotten about this until I was ready to commit this
patch.  I think this one is better since I think we could construct a
situation where both initializations are needed; on the ecj branch we
only initialize the field's context class, but that seems
insufficient.

I don't have a test case for checkin because it would rely on a
compiler other than gcj.  However I think there is a test case on the
ecj branch (which works because that branch always uses ecj...)

Tested on x86 FC5.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	PR java/28754:
	* expr.c (expand_java_field_op): Initialize field's declaring
	interface if necessary.

Index: expr.c
===================================================================
--- expr.c	(revision 116889)
+++ expr.c	(working copy)
@@ -2837,7 +2837,12 @@
   field_ref = build_field_ref (field_ref, self_type, field_name);
   if (is_static
       && ! flag_indirect_dispatch)
-    field_ref = build_class_init (self_type, field_ref);
+    {
+      tree context = DECL_CONTEXT (field_ref);
+      if (context != self_type && CLASS_INTERFACE (TYPE_NAME (context)))
+	field_ref = build_class_init (context, field_ref);
+      field_ref = build_class_init (self_type, field_ref);
+    }
   if (is_putting)
     {
       flush_quick_stack ();


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