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()
|
void TokenList::createAst()
|
||||||
{
|
{
|
||||||
for (Token *tok = _front; tok; tok = tok ? tok->next() : NULL) {
|
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;
|
std::stack<Token *> operands;
|
||||||
compileExpression(tok, operands);
|
compileExpression(tok, operands);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
|
ASSERT_EQUALS(false, testValueOfX(code, 3U, 0));
|
||||||
|
|
||||||
code = "void f(int *x) {\n"
|
code = "void f(int *x) {\n"
|
||||||
" if ((x=ret())&&\n"
|
" ((x=ret())&&\n"
|
||||||
" (*x==0));\n" // <- x is not 0
|
" (*x==0));\n" // <- x is not 0
|
||||||
" if (x==0) {}\n"
|
" if (x==0) {}\n"
|
||||||
"}";
|
"}";
|
||||||
|
|
Loading…
Reference in New Issue