Fixed #6910 (ValueFlow: variable incremented as macro argument is not known)

This commit is contained in:
Daniel Marjamäki 2015-08-05 14:08:57 +02:00
parent a51acc8abd
commit 07a064aab0
2 changed files with 11 additions and 1 deletions

View File

@ -273,7 +273,10 @@ static bool isVariableChanged(const Token *start, const Token *end, const unsign
{ {
for (const Token *tok = start; tok != end; tok = tok->next()) { for (const Token *tok = start; tok != end; tok = tok->next()) {
if (tok->varId() == varid) { if (tok->varId() == varid) {
if (Token::Match(tok, "%name% =")) if (Token::Match(tok, "%name% =|++|--"))
return true;
if (Token::Match(tok->previous(), "++|-- %name%"))
return true; return true;
if (Token::Match(tok->tokAt(-2), "[(,] & %var% [,)]")) if (Token::Match(tok->tokAt(-2), "[(,] & %var% [,)]"))

View File

@ -1672,6 +1672,13 @@ private:
"}\n"; "}\n";
ASSERT(isNotKnownValues(code, "!")); ASSERT(isNotKnownValues(code, "!"));
code = "void f() {\n"
" int x = 0;\n"
" MACRO( v, { if (y) { x++; } } );\n"
" if (!x) {}\n"
"}\n";
ASSERT(isNotKnownValues(code, "!"));
code = "void f() {\n" code = "void f() {\n"
" int x = 0;\n" " int x = 0;\n"
" for (int i = 0; i < 10; i++) {\n" " for (int i = 0; i < 10; i++) {\n"