Fixed bug 1190461 - UnusedLocal no longer misses usages which are on the RHS of a right bit shift operator.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3455 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2005-04-27 22:02:40 +00:00
parent 6c08e8b76a
commit a104045fd7
5 changed files with 21 additions and 2 deletions

View File

@ -7,6 +7,7 @@ Fixed bug 1182755 - SystemPrintln no longer overreports problems.
Fixed bug 1183032 - The XMLRenderer no longer throws a SimpleDateFormat exception when run with JDK 1.3.
Fixed bug 1188372 - AtLeastOneConstructor no longer fires on interfaces.
Fixed bug 1190508 - UnnecessaryBooleanAssertion no longer fires on nested boolean literals.
Fixed bug 1190461 - UnusedLocal no longer misses usages which are on the RHS of a right bit shift operator.
Implemented RFE 1171095 - LabeledStatement nodes now contain the image of the label.
Modified command line parameters; removed -jdk15 and -jdk13 parameters and added a -'targetjdk [1.3|1.4|1.5]' parameter.
Modified CSVRenderer to include more columns.

View File

@ -1534,8 +1534,8 @@ void ShiftExpression() :
AdditiveExpression() {checkForDiscard(jjtThis);}
(
( "<<" {jjtThis.setImage("<<");jjtThis.setUnDiscardable();}
| RSIGNEDSHIFT()
| RUNSIGNEDSHIFT()
| RSIGNEDSHIFT() {jjtThis.setImage("<<");jjtThis.setUnDiscardable();}
| RUNSIGNEDSHIFT() {jjtThis.setImage("<<");jjtThis.setUnDiscardable();}
) AdditiveExpression() )*
}

View File

@ -38,6 +38,7 @@ public class UnusedLocalVariableTest extends SimpleAggregatorTst {
new TestDescriptor(TEST17, "local variable used in postfix expression as child of StatementExpression", 1, rule),
new TestDescriptor(TEST18, "local variable used in postfix expression on right hand side", 0, rule),
new TestDescriptor(TEST19, "local variable, object ref, public field of which is incremented via in postfix expression", 0, rule),
new TestDescriptor(TEST20, "local used in right shift", 0, rule),
});
}
@ -204,4 +205,13 @@ public class UnusedLocalVariableTest extends SimpleAggregatorTst {
" b.x++; " + PMD.EOL +
" }" + PMD.EOL +
"}";
private static final String TEST20 =
"public class Foo {" + PMD.EOL +
" void bar() {" + PMD.EOL +
" int x = 2;" + PMD.EOL +
" int y = 4 >> x;" + PMD.EOL +
" foo(y);" + PMD.EOL +
" }" + PMD.EOL +
"}";
}

View File

@ -28,4 +28,10 @@ public class ASTInitializer extends SimpleNode {
public void setStatic() {
isStatic = true;
}
public void dump(String prefix) {
System.out.println(toString(prefix) + ":(" + (isStatic ? "static" : "nonstatic") + ")");
dumpChildren(prefix);
}
}

View File

@ -2777,8 +2777,10 @@ jjtn000.setModifiers(modifiers);
jj_la1[69] = jj_gen;
if (jj_2_20(1)) {
RSIGNEDSHIFT();
jjtn000.setImage("<<");jjtn000.setUnDiscardable();
} else if (jj_2_21(1)) {
RUNSIGNEDSHIFT();
jjtn000.setImage("<<");jjtn000.setUnDiscardable();
} else {
jj_consume_token(-1);
throw new ParseException();