AssignIf: added todo test case (pass variable by value to function)
This commit is contained in:
parent
39ba0d36c1
commit
1bebf1fd7e
|
@ -100,6 +100,7 @@ bool CheckAssignIf::assignIfParseScope(const Token * const assignTok,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Token::Match(tok2, "[(,] &| %varid% [,)]", varid))
|
if (Token::Match(tok2, "[(,] &| %varid% [,)]", varid))
|
||||||
|
// TODO: don't bailout if variable is passed by value
|
||||||
return true;
|
return true;
|
||||||
if (tok2->str() == "}")
|
if (tok2->str() == "}")
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -166,6 +166,14 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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"
|
check("void f(int x) {\n"
|
||||||
" extern int y; y = x & 7;\n"
|
" extern int y; y = x & 7;\n"
|
||||||
" do_something();\n"
|
" do_something();\n"
|
||||||
|
|
Loading…
Reference in New Issue