This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: [committed] allow assert in inner class
- From: Per Bothner <per at bothner dot com>
- To: Jeff Sturm <jsturm at one-point dot com>
- Cc: gcc-patches at gcc dot gnu dot org, java at gcc dot gnu dot org
- Date: Fri, 27 Feb 2004 17:07:13 -0800
- Subject: Re: [committed] allow assert in inner class
- References: <Pine.LNX.4.44.0402261256070.20846-100000@ops2.one-point.com>
Jeff Sturm wrote:
build_assertion really should use build_incomplete_class_ref, not
build_dot_class_method_invocation. The former already handles the case
where GET_CPC is an inner class or interface.
I checked in a patch to do this, as attached.
I don't know whether this is appropriate for 3.4; I don't think
it counts as a regression, but it does fix some PRs.
This caused one regression running Jacks:
non-jls-jsr41.3-runtime-2 "Asserts do not cause class initialization"
(which is in jacks/tests/runtime/non-jls/assert/tests.tcl).
The test case does work work when compiling to native, but
fails when compiling to bytecode. However, JDK 1.4.2 fails
in the same manner, and there is something to be said for
compatibility. I haven't tried to see what JDK 1.5.0 does.
I think this patch is ok, but we should revisit this after
1.5.0 is released (i.e. not beta).
Presumably we should mark this as a Jacks XFAIL; could someone
with a Jacks account do that?
--
--Per Bothner
per@bothner.com http://per.bothner.com/
2004-02-27 Per Bothner <per@bothner.com>
* parse.y (build_assertion): Re-do 02-25 change following Jeff Sturm
suggestion: Use build_incomplete_class_ref.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.471
diff -u -p -r1.471 parse.y
--- parse.y 26 Feb 2004 15:34:05 -0000 1.471
+++ parse.y 28 Feb 2004 00:27:16 -0000
@@ -15302,10 +15302,6 @@ build_assertion (int location, tree cond
{
tree field, classdollar, id, call;
tree class_type = TREE_TYPE (klass);
- tree outer_class = klass;
- while (INNER_CLASS_DECL_P (outer_class))
- outer_class = DECL_CONTEXT (outer_class);
- outer_class = TREE_TYPE (outer_class);
field = add_field (class_type,
get_identifier ("$assertionsDisabled"),
@@ -15314,10 +15310,7 @@ build_assertion (int location, tree cond
MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (field);
FIELD_SYNTHETIC (field) = 1;
- if (!TYPE_DOT_CLASS (outer_class))
- build_dot_class_method (outer_class);
- classdollar
- = build_dot_class_method_invocation (outer_class, class_type);
+ classdollar = build_incomplete_class_ref (location, class_type);
/* Call CLASS.desiredAssertionStatus(). */
id = build_wfl_node (get_identifier ("desiredAssertionStatus"));