Fixed #1013 (autovariables: detect when assigning parameter **par)
http://sourceforge.net/apps/trac/cppcheck/ticket/1013
This commit is contained in:
parent
b816968f28
commit
82ae064218
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue