Fixed #2346 (False positive: pointer is assigned value that is never used. used here: 'pCol = pCol->GetNext()')

This commit is contained in:
Daniel Marjamäki 2010-12-25 19:17:53 +01:00
parent 10ee43790d
commit ecad249ae2
2 changed files with 16 additions and 0 deletions

View File

@ -1667,6 +1667,10 @@ void CheckOther::functionVariableUsage()
else
variables.write(varid1);
}
else if (Token::Match(tok, "%varid% .", varid1))
{
variables.use(varid1);
}
else
{
variables.write(varid1);

View File

@ -80,6 +80,7 @@ private:
TEST_CASE(localvar30);
TEST_CASE(localvar31); // ticket #2286
TEST_CASE(localvar32); // ticket #2330
TEST_CASE(localvar33); // ticket #2346
TEST_CASE(localvaralias1);
TEST_CASE(localvaralias2); // ticket #1637
TEST_CASE(localvaralias3); // ticket #1639
@ -1346,6 +1347,17 @@ private:
ASSERT_EQUALS("", errout.str());
}
void localvar33() // ticket #2345
{
functionVariableUsage("void f() {\n"
" Abc* abc = getabc();\n"
" while (0 != (abc = abc->next())) {\n"
" ++nOldNum;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void localvaralias1()
{
functionVariableUsage("void foo()\n"