Fixed ticket #228: false positive with usage of an auto-variable
This commit is contained in:
parent
6f7f8c4b4f
commit
c88a362893
|
@ -147,19 +147,25 @@ void CheckAutoVariables::autoVariables()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Token::Match(tok, "%type% %var% (") ||
|
if (Token::Match(tok, "%type% %var% (") ||
|
||||||
Token::Match(tok, "%type% * %var% (") ||
|
Token::Match(tok, "%type% * %var% (") ||
|
||||||
Token::Match(tok, "%type% :: %var% ("))
|
Token::Match(tok, "%type% :: %var% ("))
|
||||||
{
|
{
|
||||||
begin_function = true;
|
begin_function = true;
|
||||||
fp_list.clear();
|
fp_list.clear();
|
||||||
vd_list.clear();
|
vd_list.clear();
|
||||||
}
|
}
|
||||||
else if (begin_function && begin_function_decl && Token::Match(tok, "%type% * %var%"))
|
else if (begin_function && begin_function_decl && Token::Match(tok, "%type% * * %var%"))
|
||||||
|
{
|
||||||
|
std::string var_name;
|
||||||
|
|
||||||
|
var_name = tok->tokAt(3)->str();
|
||||||
|
fp_list.push_back(var_name);
|
||||||
|
}
|
||||||
|
else if (begin_function && begin_function_decl && Token::Match(tok, "%type% * %var% ["))
|
||||||
{
|
{
|
||||||
std::string var_name;
|
std::string var_name;
|
||||||
|
|
||||||
var_name = tok->tokAt(2)->str();
|
var_name = tok->tokAt(2)->str();
|
||||||
//cout << "FP " << tok->linenr() << " " << var_name << endl;
|
|
||||||
fp_list.push_back(var_name);
|
fp_list.push_back(var_name);
|
||||||
}
|
}
|
||||||
else if (begin_function && Token::Match(tok, "("))
|
else if (begin_function && Token::Match(tok, "("))
|
||||||
|
|
|
@ -70,7 +70,7 @@ private:
|
||||||
|
|
||||||
void testautovar()
|
void testautovar()
|
||||||
{
|
{
|
||||||
check("void func1(int *res)\n"
|
check("void func1(int **res)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int num=2;"
|
" int num=2;"
|
||||||
"res=#");
|
"res=#");
|
||||||
|
|
Loading…
Reference in New Issue