Bug 8432 - Misleading error message for undeclared variable in inner class
Summary: Misleading error message for undeclared variable in inner class
Status: RESOLVED DUPLICATE of bug 4811
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2002-11-02 17:36 UTC by jmr
Modified: 2004-01-07 20:01 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-11-20 17:58:01


Attachments
InnerStaticFinal.java (101 bytes, application/octet-stream)
2003-05-21 15:17 UTC, jmr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jmr 2002-11-02 17:36:00 UTC
If a variable isn't declared in an inner class, an error message is issued saying that the local variable must be declared final.  It would be better to say that the variable is undeclared.

Release:
3.3 20021101 (experimental)

Environment:
System: Linux churchill 2.4.3-12 #1 Fri Jun 8 15:05:56 EDT 2001 i686 unknown
Architecture: i686

        <machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/home/user/jmr/app/gcc --enable-languages=c++,java --enable-threads=posix --enable-shared --with-as=/home/user/jmr/app/binutils/bin/as --with-ld=/home/user/jmr/app/binutils/bin/ld : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)  : (reconfigured)

How-To-Repeat:
; cat InnerStaticFinal.java
public class InnerStaticFinal {
    private static final class Inner extends Base {
        private Inner () {
            super (foo);
        }
    }
}

; cat Base.java
public class Base {
    public Base (Object o) {
    }
}

; gcj Base.java InnerStaticFinal.java 
InnerStaticFinal.java: In class `InnerStaticFinal$Inner':
InnerStaticFinal.java: In constructor `()':
InnerStaticFinal.java:4: error: Local variable `foo' can't be accessed from within the inner class `InnerStaticFinal$Inner' unless it is declared final.
               super (foo);
                      ^
1 error

; javac Base.java InnerStaticFinal.java 
InnerStaticFinal.java:4: cannot resolve symbol
symbol  : variable foo  
location: class InnerStaticFinal.Inner
            super (foo);
                   ^
1 error
Comment 1 Andrew Pinski 2003-05-25 22:50:20 UTC
Confirmed on mainline (20030525):
tin:~/src/gnu/gcctest>gcj Base.java InnerStaticFinal.java
InnerStaticFinal.java: In class `InnerStaticFinal$Inner':
InnerStaticFinal.java: In constructor `()':
InnerStaticFinal.java:5: error: Local variable `foo' can't be accessed from within the inner 
class `InnerStaticFinal$Inner' unless it is declared final.
               super (foo);
                      ^
1 error
Comment 2 Andrew Pinski 2004-01-07 20:01:37 UTC
This is a dup of bug 4811.

*** This bug has been marked as a duplicate of 4811 ***