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]

Re: Fwd: [JAVA, PATCH] PR java/8923: ICE when modifying a variable decleared "final static"


Hi all.

Here's the revised patch I sent to gcc-patches@. It is a possible fix for the 
whole PR. I'm sorry to have forgotten java-patches@ in this mail and the 
previous one...

Best regards,
Simon

----------  Forwarded Message  ----------

Subject: Re: [JAVA, PATCH] PR java/8923: ICE when modifying a variable 
decleared "final static"
Date: Friday 28 July 2006 07:58
From: Simon Martin <simartin@users.sourceforge.net>
To: gcc-patches@gcc.gnu.org

Hi again.

[...]

> I haven't figured a fix for the initial test case yet:
>
> === cut here ===
> public class myBug
> {
>         final static int myConst = 200;
>
>         public static void bug() { myConst++;   /* ICE */ }
> }
> === cut here ===
>
> A good place to emit an error would be in check-init.c(check_init), because
> that's there that we get an error if myConst is not declared static. From
> my investigation, it looks like we currently don't see that myConst is
> final because it has been constant fold, and we get an INTEGER_CST. Is
> there a way to get back to the declaration from there? I guess that adding
> a check for INTEGER_CST in check_init would fix the problem, but I wonder
> if it's a "good" solution...

The attached patch completely solves the PR by calling 'java_complete_lhs'
instead of 'java_complete_tree' on the operand of '++' or '--' expression in
'java_complete_lhs'. This change guarantees that the operand will never be
resolved to its value. Thanks to this, check_init emits an error instead of
an ICE when we compile the PR's initial test case.

I also attach two test cases (they're not merged because the "1++" situation
is detected in the parser, whereas the "static final++" situation is detected
later on).

Boostrapped and regtested on i686-pc-linux-gnu. Is it OK? If so, could
 someone commit it for me?

Thanks in advance.

Best regards,
Simon

-------------------------------------------------------

Attachment: CL_8923_2
Description: Text document

Attachment: pr8923_2.patch
Description: Text document

Attachment: pr8923_1.java
Description: Text document

Attachment: pr8923_2.java
Description: Text document


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