ast: fixed syntax tree for statement enclosed in parentheses ';(expr);'
This commit is contained in:
parent
ceca6be22b
commit
1fc2c9fe79
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue