Fixed #2264 (False positive: variable assigned value that is never used)
This commit is contained in:
parent
b29568c81d
commit
93ebdca313
|
@ -1650,6 +1650,8 @@ void CheckOther::functionVariableUsage()
|
|||
variables.writeAliases(tok->varId());
|
||||
variables.read(tok->varId());
|
||||
}
|
||||
else if (tok->varId() != varid1 && Token::Match(tok, "%var% . %var%"))
|
||||
variables.use(tok->varId());
|
||||
}
|
||||
|
||||
const Token *equal = tok->next();
|
||||
|
|
|
@ -76,6 +76,7 @@ private:
|
|||
TEST_CASE(localvar27); // ticket #2160
|
||||
TEST_CASE(localvar28); // ticket #2205
|
||||
TEST_CASE(localvar29); // ticket #2206 (array initialization)
|
||||
TEST_CASE(localvar30);
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
TEST_CASE(localvaralias3); // ticket #1639
|
||||
|
@ -1305,6 +1306,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar30() // ticket #2264
|
||||
{
|
||||
functionVariableUsage("void f() {\n"
|
||||
" Engine *engine = e;\n"
|
||||
" x->engine = engine->clone();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1()
|
||||
{
|
||||
functionVariableUsage("void foo()\n"
|
||||
|
|
Loading…
Reference in New Issue