diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 2788663b6..4bdcd576b 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -288,11 +288,9 @@ bool isVariableChanged(const Token *start, const Token *end, const unsigned int const Token *parent = tok->astParent(); while (parent && parent->str() == ",") parent = parent->astParent(); - if (parent && parent->str() == "(") { - if (parent->astOperand1() && parent->astOperand1()->isName() && !parent->astOperand1()->function()) - return true; - // TODO: check if function parameter is non-const reference etc.. - } + if (parent && Token::Match(parent->previous(), "%name% (") && !parent->previous()->function()) + return true; + // TODO: check if function parameter is non-const reference etc.. } const Token *parent = tok->astParent(); diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 513f9ab09..37294df9e 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1692,6 +1692,15 @@ private: "}\n"; ASSERT(isNotKnownValues(code, "<")); + code = "void f() {\n" + " int x = 0;\n" + " do {\n" + " if (x < 0) {}\n" + " fred.dostuff(x);\n" + " } while (abc);\n" + "}\n"; + ASSERT(isNotKnownValues(code, "<")); + code = "void f() {\n" " int x = 0;\n" " if (y) { dostuff(x); }\n"