diff --git a/lib/checkassignif.cpp b/lib/checkassignif.cpp index 69474f6a8..12e94f2d8 100644 --- a/lib/checkassignif.cpp +++ b/lib/checkassignif.cpp @@ -100,6 +100,7 @@ bool CheckAssignIf::assignIfParseScope(const Token * const assignTok, return true; } if (Token::Match(tok2, "[(,] &| %varid% [,)]", varid)) + // TODO: don't bailout if variable is passed by value return true; if (tok2->str() == "}") return false; diff --git a/test/testassignif.cpp b/test/testassignif.cpp index 498db206b..3b8271518 100644 --- a/test/testassignif.cpp +++ b/test/testassignif.cpp @@ -166,6 +166,14 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("void do_something(int);\n" + "void f(int x) {\n" + " int y = x & 7;\n" + " do_something(y);\n" // passing variable by value => error + " if (y==8);\n" + "}"); + TODO_ASSERT_EQUALS("error", "", errout.str()); + check("void f(int x) {\n" " extern int y; y = x & 7;\n" " do_something();\n"