This is the mail archive of the
mailing list for the GCC project.
Patch: FYI: PR 28754
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 12 Sep 2006 09:48:43 -0600
- Subject: Patch: FYI: PR 28754
- Reply-to: tromey at redhat dot com
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
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.
from Tom Tromey <firstname.lastname@example.org>
* expr.c (expand_java_field_op): Initialize field's declaring
interface if necessary.
--- expr.c (revision 116889)
+++ expr.c (working copy)
@@ -2837,7 +2837,12 @@
field_ref = build_field_ref (field_ref, self_type, field_name);
&& ! 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);