ast: fixed syntax tree for statement enclosed in parentheses ';(expr);'

This commit is contained in:
Daniel Marjamäki 2014-01-11 15:18:39 +01:00
parent ceca6be22b
commit 1fc2c9fe79
2 changed files with 3 additions and 3 deletions

View File

@ -687,7 +687,7 @@ static void compileExpression(Token *&tok, std::stack<Token*> &op)
void TokenList::createAst()
{
for (Token *tok = _front; tok; tok = tok ? tok->next() : NULL) {
if (tok->str() == "return" || !tok->previous() || Token::Match(tok, "%var% %op%|(|[|.|=|::") || Token::Match(tok->previous(), "[;{}] %cop%")) {
if (tok->str() == "return" || !tok->previous() || Token::Match(tok, "%var% %op%|(|[|.|=|::") || Token::Match(tok->previous(), "[;{}] %cop%|(")) {
std::stack<Token *> operands;
compileExpression(tok, operands);
}

View File

@ -114,8 +114,8 @@ private:
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
code = "void f(int *x) {\n"
" if ((x=ret())&&\n"
" (*x==0));\n" // <- x is not 0
" ((x=ret())&&\n"
" (*x==0));\n" // <- x is not 0
" if (x==0) {}\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));