Fixed #1807 (false positive: Variable is not assigned a value (casting function parameters))
This commit is contained in:
parent
d22da6088c
commit
a5b45a7f83
|
@ -1325,6 +1325,9 @@ void CheckOther::functionVariableUsage()
|
|||
variables.use(tok->next()->varId()); // use = read + write
|
||||
else if (Token::Match(tok, "[(,] %var% [,)]") && tok->previous()->str() != "*")
|
||||
variables.use(tok->next()->varId()); // use = read + write
|
||||
else if (Token::Match(tok, "[(,] (") &&
|
||||
Token::Match(tok->next()->link(), ") %var% [,)]"))
|
||||
variables.use(tok->next()->link()->next()->varId()); // use = read + write
|
||||
|
||||
// function
|
||||
else if (Token::Match(tok, " %var% ("))
|
||||
|
|
|
@ -66,6 +66,7 @@ private:
|
|||
TEST_CASE(localvar18); // ticket #1723
|
||||
TEST_CASE(localvar19); // ticket #1776
|
||||
TEST_CASE(localvar20); // ticket #1799
|
||||
TEST_CASE(localvar21); // ticket #1807
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
TEST_CASE(localvaralias3); // ticket #1639
|
||||
|
@ -1177,6 +1178,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar21() // ticket #1807
|
||||
{
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
" char buffer[1024];\n"
|
||||
" bar((void *)buffer);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1()
|
||||
{
|
||||
functionVariableUsage("void foo()\n"
|
||||
|
|
Loading…
Reference in New Issue