From 1fc2c9fe793897fe59b95152616f70a81a4708c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 11 Jan 2014 15:18:39 +0100 Subject: [PATCH] ast: fixed syntax tree for statement enclosed in parentheses ';(expr);' --- lib/tokenlist.cpp | 2 +- test/testvalueflow.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index a1900f2e5..cd55145b9 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -687,7 +687,7 @@ static void compileExpression(Token *&tok, std::stack &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 operands; compileExpression(tok, operands); } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index df0a49c54..e12c712ee 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -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));