Bug 11389

Summary: Unused parameters not showing up as compiler warnings
Product: [Eclipse Project] JDT Reporter: DJ Houghton <dj.houghton>
Component: CoreAssignee: 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 CLA 2002-03-14 14:23:55 EST
build 2002-03-12 on Win98.

I have this option turned on in the preferences to display a warning but no 
tasks are created in the task list and there is no icon in the Java file.

I switched this option to be an Error and I get the same results.

I can provide the method if required, although its pretty simple.
Comment 1 Olivier Thomann CLA 2002-03-14 16:37:27 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)) ....
Comment 2 Philipe Mulet CLA 2002-03-15 17:56:18 EST
Good guess Olivier, the proper fix is to set the bits inside the Argument 
constructor.
Comment 3 Olivier Thomann CLA 2002-03-15 19:55:57 EST
Fixed and released in HEAD.