Fixed #1607 (false positive: variable is assigned a value that is never used)
This commit is contained in:
parent
0d30b840dc
commit
d851b4a3d4
|
@ -573,20 +573,9 @@ void CheckOther::functionVariableUsage()
|
|||
if (tok->next()->str() != "return")
|
||||
{
|
||||
varUsage[tok->strAt(3)].declare = true;
|
||||
varUsage[tok->strAt(3)].aliased = true;
|
||||
if (tok->tokAt(4)->str() == "=")
|
||||
{
|
||||
varUsage[tok->strAt(3)].write = true;
|
||||
if (Token::Match(tok->tokAt(5), "%var% = &| %var%") &&
|
||||
tok->tokAt(5)->str() == tok->tokAt(3)->str())
|
||||
{
|
||||
varUsage[tok->strAt(3)].aliased = true;
|
||||
}
|
||||
}
|
||||
else if (Token::Match(tok->tokAt(5), "%var% = &| %var%") &&
|
||||
tok->tokAt(5)->str() == tok->tokAt(3)->str())
|
||||
{
|
||||
varUsage[tok->strAt(3)].aliased = true;
|
||||
}
|
||||
tok = tok->tokAt(3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,13 +332,13 @@ private:
|
|||
"{\n"
|
||||
" int * i = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used\n", errout.str());
|
||||
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
" void * i = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'i' is assigned a value that is never used\n", errout.str());
|
||||
}
|
||||
|
||||
void localvar2()
|
||||
|
|
Loading…
Reference in New Issue