From 1bebf1fd7eedb119e14dd625b5b0ec95513927e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 29 Jul 2013 12:27:57 +0200 Subject: [PATCH] AssignIf: added todo test case (pass variable by value to function) --- lib/checkassignif.cpp | 1 + test/testassignif.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) 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"