Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands. (#2429)

* Fix issue 9514: Syntax Error: AST broken, 'for' doesn't have two operands.

* Fix typo
This commit is contained in:
Paul Fultz II 2019-12-07 14:16:25 -06:00 committed by Daniel Marjamäki
parent 56e17fb228
commit ea2916a3e4
2 changed files with 9 additions and 1 deletions

View File

@ -883,7 +883,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
compileUnaryOp(tok, state, compileExpression);
else
compileBinOp(tok, state, compileExpression);
if (Token::simpleMatch(tok, "}"))
while (Token::simpleMatch(tok, "}"))
tok = tok->next();
} else break;
}

View File

@ -474,6 +474,7 @@ private:
TEST_CASE(checkLambdas);
TEST_CASE(checkIfCppCast);
TEST_CASE(checkRefQualifiers);
TEST_CASE(checkConditionBlock);
// #9052
TEST_CASE(noCrash1);
@ -7692,6 +7693,7 @@ private:
ASSERT_EQUALS("Abc({newreturn", testAst("return new A {b(c)};"));
ASSERT_EQUALS("a{{return", testAst("return{{a}};"));
ASSERT_EQUALS("a{b{,{return", testAst("return{{a},{b}};"));
ASSERT_EQUALS("stdvector::", testAst("std::vector<std::vector<int>>{{},{}}"));
}
void astbrackets() { // []
@ -8178,6 +8180,12 @@ private:
}
void checkConditionBlock() {
ASSERT_NO_THROW(tokenizeAndStringify("void a() {\n"
" for (auto b : std::vector<std::vector<int>>{{}, {}}) {}\n"
"}\n"))
}
void noCrash1() {
ASSERT_NO_THROW(tokenizeAndStringify(
"struct A {\n"