mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix bug 64010: if else if recursion looks like stack overflow
This commit is contained in:
parent
3ae5819d17
commit
ef506f545b
2 changed files with 24 additions and 1 deletions
|
@ -1867,4 +1867,23 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
|
||||
|
||||
}
|
||||
|
||||
public void testBug64010() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( " #define ONE else if (0) { } \n");
|
||||
writer.write( " #define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE \n ");
|
||||
writer.write( " #define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN \n ");
|
||||
writer.write( " #define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN \n");
|
||||
writer.write("void foo() ");
|
||||
writer.write("{ ");
|
||||
writer.write(" if (0) { } ");
|
||||
writer.write(" /* 11,000 else if's. */ ");
|
||||
writer.write(" THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU ");
|
||||
writer.write("} ");
|
||||
|
||||
Iterator d = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTFunction f = (IASTFunction) d.next();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2855,7 +2855,11 @@ public abstract class Parser extends ExpressionParser implements IParser
|
|||
if (LT(1) == IToken.t_else)
|
||||
{
|
||||
consume( IToken.t_else );
|
||||
if( LT(1) != IToken.tLBRACE )
|
||||
if( LT(1) == IToken.t_if ){
|
||||
//an else if, return and get the rest of the else if as the next statement instead of recursing
|
||||
cleanupLastToken();
|
||||
return;
|
||||
} else if( LT(1) != IToken.tLBRACE )
|
||||
singleStatementScope(scope);
|
||||
else
|
||||
statement( scope );
|
||||
|
|
Loading…
Add table
Reference in a new issue