public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch: FYI: PR 28754
@ 2006-09-12 15:55 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2006-09-12 15:55 UTC (permalink / raw)
  To: Java Patch List; +Cc: Gcc Patch List

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 ();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-12 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-12 15:55 Patch: FYI: PR 28754 Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).