Fixed #1013 (autovariables: detect when assigning parameter **par)

http://sourceforge.net/apps/trac/cppcheck/ticket/1013
This commit is contained in:
Slava Semushin 2010-01-02 03:53:34 +06:00
parent b816968f28
commit 82ae064218
2 changed files with 7 additions and 3 deletions

View File

@ -198,7 +198,10 @@ void CheckAutoVariables::autoVariables()
{
errorAutoVariableAssignment(tok);
}
//Critical assignment
else if (Token::Match(tok, "[;{}] * %var% = & %var%") && errorAv(tok->tokAt(2), tok->tokAt(5)))
{
errorAutoVariableAssignment(tok);
}
else if (Token::Match(tok, "[;{}] %var% [ %any% ] = & %var%") && errorAv(tok->tokAt(1), tok->tokAt(7)))
{
errorAutoVariableAssignment(tok);

View File

@ -77,8 +77,9 @@ private:
{
check("void func1(int **res)\n"
"{\n"
" int num=2;"
"res=#}");
" int num = 2;\n"
" *res = #\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Wrong assignment of an auto-variable to an effective parameter of a function\n", errout.str());
check("void func1(int **res)\n"