1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 472950 - Account for the possibility of statements inside

expressions in some of the parser's heuristic checks

Change-Id: Ia91a00b91e0050838e990d1daad81b524816f8d0
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
Nathan Ridge 2015-07-18 01:28:00 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 4459b9a317
commit 005d40d228
2 changed files with 24 additions and 1 deletions

View file

@ -4662,6 +4662,15 @@ public class AST2Tests extends AST2TestBase {
parseAndCheckBindings(code, CPP, true);
}
// int main() {
// (typeof(({ 0; }))) 0;
// }
public void testTypeofStatementExpressionInCastExpression_427950() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, C, true);
parseAndCheckBindings(code, CPP, true);
}
// void test(int count) {
// __typeof__(count) a= 1;
// int ret0 = ((__typeof__(count)) 1);

View file

@ -2664,9 +2664,23 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
protected void skipBrackets(int left, int right, int terminator) throws EndOfFileException, BacktrackException {
consume(left);
int nesting= 0;
int nesting = 0;
int braceNesting = 0;
while (true) {
final int lt1= LT(1);
// Ignore passages inside braces (such as for a statement-expression),
// as they can basically contain tokens of any kind.
if (lt1 == IToken.tLBRACE) {
braceNesting++;
} else if (lt1 == IToken.tRBRACE) {
braceNesting--;
}
if (braceNesting > 0) {
consume();
continue;
}
if (lt1 == IToken.tEOC || lt1 == terminator)
throwBacktrack(LA(1));