Bug 14853 - [3.3/3.4 Regression] Assignment to final field permitted when compiling to native
Summary: [3.3/3.4 Regression] Assignment to final field permitted when compiling to na...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 3.4.4
Assignee: Tom Tromey
URL:
Keywords: accepts-invalid
Depends on:
Blocks: 13607
  Show dependency treegraph
 
Reported: 2004-04-05 15:04 UTC by Michael Koch
Modified: 2004-12-08 18:09 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 3.0.4
Known to fail: 4.0.0 3.4.0 3.3.3 3.2.3
Last reconfirmed: 2004-11-09 06:01:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Koch 2004-04-05 15:04:43 UTC
When compiling the following code with "gcj -C" an error message orrurs 
correctly as with other java compilers too. With "gcj -c" this code gets 
compiled successfully (incorrectly) and works, but it should be rejected too. 
 
public class FinalTest 
{ 
public static void main (String[] args) 
{ 
        System.out = new java.io.PrintStream(null); 
} 
}
Comment 1 Andrew Pinski 2004-04-05 15:12:56 UTC
Confirmed.
Here is an example not dependent on System.out and shows the problem more clearly:
class tt
{
  static final tt tt1 = new tt();
  tt()
  {
  }
}
public class FinalTest
{
public static void main (String[] args)
{
        tt.tt1 = new tt();
}
}
Comment 2 Andrew Pinski 2004-04-05 15:53:11 UTC
This is a regression from 3.0.4.
Comment 3 Giovanni Bajo 2004-06-06 03:50:28 UTC
Retargeting to 3.4.1, being a regression on that release branch.
Comment 4 Mark Mitchell 2004-06-12 21:56:14 UTC
Postponed until GCC 3.4.2.
Comment 5 Mark Mitchell 2004-08-19 20:47:00 UTC
Postponed until GCC 3.4.3.
Comment 6 Mark Mitchell 2004-11-01 00:45:08 UTC
Postponed until GCC 3.4.4.
Comment 7 Tom Tromey 2004-12-04 00:28:58 UTC
I looked into this today.

When compiling to .o (or with --syntax-only), the
"System.out" reference is wrapped in a compound_expr
whose LHS initializes the System class.

I'm working on this.
Comment 8 GCC Commits 2004-12-06 15:31:06 UTC
Subject: Bug 14853

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2004-12-06 15:30:57

Modified files:
	libjava        : ChangeLog 
Added files:
	libjava/testsuite/libjava.compile: PR14853.java PR14853.xfail 

Log message:
	For PR java/14853:
	* testsuite/libjava.compile/PR14853.java: New file.
	* testsuite/libjava.compile/PR14853.xfail: New file.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3259&r2=1.3260
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/PR14853.java.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/PR14853.xfail.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 9 GCC Commits 2004-12-06 15:32:43 UTC
Subject: Bug 14853

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2004-12-06 15:32:38

Modified files:
	gcc/java       : ChangeLog java-tree.h parse.y check-init.c 

Log message:
	PR java/14853:
	* java-tree.h (extract_field_decl): Declare.
	* parse.y (extract_field_decl): Renamed from
	strip_out_static_field_access_decl.  No longer static.
	* check-init.c (get_variable_decl): Unwrap COMPOUND_EXPRs.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1516&r2=1.1517
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/java-tree.h.diff?cvsroot=gcc&r1=1.223&r2=1.224
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.524&r2=1.525
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/check-init.c.diff?cvsroot=gcc&r1=1.61&r2=1.62

Comment 10 Tom Tromey 2004-12-06 15:33:59 UTC
Fix checked in, will appear in gcc 4.0
Comment 11 Giovanni Bajo 2004-12-06 18:31:32 UTC
This is a regression on active branches, so the bug should stay open until it's 
fixed there. Is a backport of your patch feasable for the 3.4 and 3.3 branches?
Comment 12 Tom Tromey 2004-12-06 18:34:41 UTC
The patch should probably apply as-is to 3.4.
Comment 13 Giovanni Bajo 2004-12-06 18:38:38 UTC
Will you test it there then?
Comment 14 Tom Tromey 2004-12-07 17:07:41 UTC
I'm building this for 3.4 right now.
If it works ok I will submit it.
I don't plan to try it for 3.3.
Comment 15 GCC Commits 2004-12-08 17:29:11 UTC
Subject: Bug 14853

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	tromey@gcc.gnu.org	2004-12-08 17:29:02

Modified files:
	libjava        : ChangeLog 
Added files:
	libjava/testsuite/libjava.compile: PR14853.java PR14853.xfail 

Log message:
	For PR java/14853:
	* testsuite/libjava.compile/PR14853.java: New file.
	* testsuite/libjava.compile/PR14853.xfail: New file.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2562.2.26&r2=1.2562.2.27
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/PR14853.java.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/testsuite/libjava.compile/PR14853.xfail.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 16 GCC Commits 2004-12-08 17:29:46 UTC
Subject: Bug 14853

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	tromey@gcc.gnu.org	2004-12-08 17:29:42

Modified files:
	gcc/java       : ChangeLog check-init.c java-tree.h parse.y 

Log message:
	PR java/14853:
	* java-tree.h (extract_field_decl): Declare.
	* parse.y (extract_field_decl): Renamed from
	strip_out_static_field_access_decl.  No longer static.
	* check-init.c (get_variable_decl): Unwrap COMPOUND_EXPRs.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1315.2.19&r2=1.1315.2.20
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/check-init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.53&r2=1.53.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/java-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.194&r2=1.194.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.464.4.2&r2=1.464.4.3

Comment 17 Andrew Pinski 2004-12-08 18:09:25 UTC
Fixed on the 3.4 branch also.