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:
parent
56e17fb228
commit
ea2916a3e4
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue