AST: fixed ast for 'for (*x=0;y;z)'

This commit is contained in:
Daniel Marjamäki 2014-03-31 17:16:13 +02:00
parent 225fb96554
commit 484483bd5d
2 changed files with 2 additions and 1 deletions

View File

@ -717,7 +717,7 @@ static Token * createAstAtToken(Token *tok)
tok2 = tok2->link();
if (!tok2)
break;
} else if (Token::Match(tok2, "%var% %op%|(|[|.|=|:|::") || Token::Match(tok2->previous(), "[;{}] %cop%|(")) {
} else if (Token::Match(tok2, "%var% %op%|(|[|.|=|:|::") || Token::Match(tok2->previous(), "[(;{}] %cop%|(")) {
init1 = tok2;
std::stack<Token *> operands;
compileExpression(tok2, operands);

View File

@ -10291,6 +10291,7 @@ private:
TODO_ASSERT_EQUALS("fori1=current0=,iNUM<=i++;;(", "fori1=current0=,i<NUM=i++;;(", testAst("for(i = (1), current = 0; i <= (NUM); ++i)"));
ASSERT_EQUALS("foreachxy,((", testAst("for(each(x,y)){}")); // it's not well-defined what this ast should be
ASSERT_EQUALS("forab:(", testAst("for (int a : b);"));
ASSERT_EQUALS("forx*0=yz;;(", testAst("for(*x=0;y;z)"));
// problems with multiple expressions
ASSERT_EQUALS("ax( whilex(", testAst("a(x) while (x)"));