Merge branch 'bug-1530'

This commit is contained in:
Andreas Dangel
2016-10-16 14:14:30 +02:00
4 changed files with 23 additions and 3 deletions

View File

@@ -1,4 +1,11 @@
/**
* Fix for regression introduced in previous changeset.
* The syntactic lookahead was not properly handled by javacc,
* so it was converted to a semantic one
* Bug #1530
*
* Juan Martin Sotuyo Dodero 10/2016
*====================================================================
* Fix for an expression within an additive expression that was
* wrongly taken as a cast expression.
* Bug #1484
@@ -1761,7 +1768,7 @@ void UnaryExpressionNotPlusMinus() #UnaryExpressionNotPlusMinus((jjtn000.getImag
{}
{
( "~" {jjtThis.setImage("~");} | "!" {jjtThis.setImage("!");} ) UnaryExpression()
| LOOKAHEAD("(" <IDENTIFIER> ")" "+") PostfixExpression()
| LOOKAHEAD( { getToken(1).kind == LPAREN && getToken(2).kind == IDENTIFIER && getToken(3).kind == RPAREN && getToken(4).kind == PLUS } ) PostfixExpression()
| LOOKAHEAD( CastExpression() ) CastExpression()
| LOOKAHEAD("(" Type() ")" "(") CastExpression()
| PostfixExpression()
@@ -1843,9 +1850,8 @@ void PrimarySuffix() :
}
void Literal() :
{}
{
{ Token t;}
{
t=<INTEGER_LITERAL> { checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setIntLiteral();}
| t=<FLOATING_POINT_LITERAL> { checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setFloatLiteral();}
| t=<HEX_FLOATING_POINT_LITERAL> { checkForBadHexFloatingPointLiteral(); checkForBadNumericalLiteralslUsage(t); jjtThis.setImage(t.image); jjtThis.setFloatLiteral();}

View File

@@ -130,6 +130,12 @@ public class ParserCornersTest extends ParserTst {
String c = IOUtils.toString(this.getClass().getResourceAsStream("Bug1429.java"));
parseJava18(c);
}
@Test
public void testBug1530ParseError() throws Exception {
String c = IOUtils.toString(this.getClass().getResourceAsStream("Bug1530.java"));
parseJava18(c);
}
/**
* This triggered bug #1484 UnusedLocalVariable - false positive - parenthesis

View File

@@ -0,0 +1,5 @@
public class Bug1530 {
public void incChild() {
((PathElement) stack.getLastLeaf().getUserObject()).currentChild++;
}
}

View File

@@ -14,9 +14,12 @@
* [#106](https://github.com/pmd/pmd/pull/106): \[java] CPD: Keep constructor names under ignoreIdentifiers
* [#107](https://github.com/pmd/pmd/pull/107): \[groovy] Initial support for CPD Groovy
* [#110](https://github.com/pmd/pmd/pull/110): \[java] Fix parser error (issue 1530)
**Bugfixes:**
* Java
* [#1530](https://sourceforge.net/p/pmd/bugs/1530/): \[java] Parser exception on Java code
* java-comments
* [#1522](https://sourceforge.net/p/pmd/bugs/1522/): \[java] CommentRequired: false positive
* java-imports/UnusedImports