Summary: | Unused parameters not showing up as compiler warnings | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | DJ Houghton <dj.houghton> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 2.0 | ||
Target Milestone: | 2.0 M4 | ||
Hardware: | Other | ||
OS: | other | ||
Whiteboard: |
Description
DJ Houghton
2002-03-14 14:23:55 EST
Reproduced. The problem is located inside BlockScope.computeLocalVariablePositions(int,CodeStream). if (!local.used && (local.declaration != null) // unused (and non secret) local && ((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable if (local.isArgument) // method argument this.problemReporter().unusedArgument(local.declaration); With the following example, the test (local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0 is false. [public class Test { public static void main(String[] args) { int i = 0; } }] I suggest the following fix: public Argument(char[] name, long posNom, TypeReference tr, int modifiers) { super(null, name, (int) (posNom >>> 32), (int) posNom); this.modifiers = modifiers; type = tr; } remplaced by: public Argument(char[] name, long posNom, TypeReference tr, int modifiers) { super(null, name, (int) (posNom >>> 32), (int) posNom); this.modifiers = modifiers; type = tr; bits |= IsLocalDeclarationReachableMASK; } because an argument of a method declaration is always reachable or move the test ((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0) into the second test if (!(local.declaration instanceof Argument)). Would be something like: if (((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0) && !(local.declaration instanceof Argument)) .... Good guess Olivier, the proper fix is to set the bits inside the Argument constructor. Fixed and released in HEAD. |