Fix crash in createAST when checking wiggle in daca@home

This commit is contained in:
Daniel Marjamäki 2020-09-26 19:22:24 +02:00
parent 5578b09452
commit 0ec77879ea
2 changed files with 2 additions and 1 deletions

View File

@ -1422,7 +1422,7 @@ static Token * createAstAtToken(Token *tok, bool cpp)
init1 = tok2;
AST_state state1(cpp);
compileExpression(tok2, state1);
if (init1->str() == "(") {
if (Token::Match(init1, "( !!{")) {
for (Token *tok3 = init1; tok3 != tok3->link(); tok3 = tok3->next()) {
if (tok3->astParent()) {
while (tok3->astParent())

View File

@ -7601,6 +7601,7 @@ private:
ASSERT_EQUALS("forab,c:(", testAst("for (auto [a,b]: c);"));
ASSERT_EQUALS("fora*++;;(", testAst("for (++(*a);;);"));
ASSERT_EQUALS("foryz:(", testAst("for (decltype(x) *y : z);"));
ASSERT_EQUALS("for(tmpNULL!=tmptmpnext.=;;( tmpa=", testAst("for ( ({ tmp = a; }) ; tmp != NULL; tmp = tmp->next ) {}"));
// problems with multiple expressions
ASSERT_EQUALS("ax( whilex(", testAst("a(x) while (x)"));