mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
bug 55163 - Parser spins on for-init-statement
This commit is contained in:
parent
7c03999239
commit
e6f4fa5890
4 changed files with 38 additions and 4 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2003-03-16 Andrew Niefer
|
||||||
|
added CompleteParseASTTest.testBug55163
|
||||||
|
|
||||||
2004-03-12 Sean Evoy
|
2004-03-12 Sean Evoy
|
||||||
Corrected a target definition in the plugin manifest that was flagged
|
Corrected a target definition in the plugin manifest that was flagged
|
||||||
as release when it should have been flagged as test. Also updated the
|
as release when it should have been flagged as test. Also updated the
|
||||||
|
|
|
@ -1476,4 +1476,26 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
assertFalse( i.hasNext() );
|
assertFalse( i.hasNext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug55163() throws Exception
|
||||||
|
{
|
||||||
|
Writer writer = new StringWriter();
|
||||||
|
writer.write( "void foo() { \n");
|
||||||
|
writer.write( " int i, n; \n");
|
||||||
|
writer.write( " double di; \n");
|
||||||
|
writer.write( " for( i = n - 1, di = (double)( i + i ); i > 0; i-- ){ } \n");
|
||||||
|
writer.write( "}\n");
|
||||||
|
|
||||||
|
Iterator iter = parse( writer.toString() ).getDeclarations();
|
||||||
|
|
||||||
|
IASTFunction foo = (IASTFunction) iter.next();
|
||||||
|
assertFalse( iter.hasNext() );
|
||||||
|
iter = getDeclarations( foo );
|
||||||
|
IASTVariable i = (IASTVariable)iter.next();
|
||||||
|
IASTVariable n = (IASTVariable)iter.next();
|
||||||
|
IASTVariable di = (IASTVariable)iter.next();
|
||||||
|
|
||||||
|
assertAllReferences( 7, createTaskList( new Task( n ), new Task( i, 5 ), new Task( di ) ) );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2004-03-17 Andrew Niefer
|
||||||
|
fix bug 55163
|
||||||
|
- in for-init-statement, try expression-statement before simple-declaration since if it actually is a statement instead of a
|
||||||
|
declaration, the simple-declaration fails hard and can actually enter an infinite loop.
|
||||||
|
|
||||||
2004-03-16 Dave Daoust
|
2004-03-16 Dave Daoust
|
||||||
refactor scanner for performance improvements
|
refactor scanner for performance improvements
|
||||||
-changes to accountForUndo, now named readFromStream
|
-changes to accountForUndo, now named readFromStream
|
||||||
|
|
|
@ -503,7 +503,7 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
templateDecl.setEndingOffsetAndLineNumber( lastToken.getEndOffset(), lastToken.getLineNumber() );
|
||||||
templateDecl.exitScope( requestor );
|
templateDecl.exitScope( requestor );
|
||||||
}
|
}
|
||||||
catch (BacktrackException bt)
|
catch (BacktrackException bt)
|
||||||
{
|
{
|
||||||
|
@ -2822,16 +2822,20 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
*/
|
*/
|
||||||
protected void forInitStatement( IASTScope scope ) throws BacktrackException, EndOfFileException
|
protected void forInitStatement( IASTScope scope ) throws BacktrackException, EndOfFileException
|
||||||
{
|
{
|
||||||
|
IToken mark = mark();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
simpleDeclarationStrategyUnion(scope,null, null);
|
IASTExpression e = expression( scope );
|
||||||
|
e.acceptElement(requestor);
|
||||||
|
|
||||||
|
consume( IToken.tSEMI );
|
||||||
}
|
}
|
||||||
catch( BacktrackException bt )
|
catch( BacktrackException bt )
|
||||||
{
|
{
|
||||||
|
backup( mark );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IASTExpression e = expression( scope );
|
simpleDeclarationStrategyUnion(scope,null, null);
|
||||||
e.acceptElement(requestor);
|
|
||||||
}
|
}
|
||||||
catch( BacktrackException b )
|
catch( BacktrackException b )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue