Bug 11389 - Unused parameters not showing up as compiler warnings
Summary: Unused parameters not showing up as compiler warnings
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: Other other
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-14 14:23 EST by DJ Houghton CLA
Modified: 2002-03-15 19:55 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.