Variable usage: read variable when using syntax '..=*(p);'
This commit is contained in:
parent
cf61d2179f
commit
00dcec47ac
|
@ -1345,7 +1345,7 @@ void CheckOther::functionVariableUsage()
|
||||||
variables.use(tok->next()->varId()); // use = read + write
|
variables.use(tok->next()->varId()); // use = read + write
|
||||||
|
|
||||||
// function parameter
|
// function parameter
|
||||||
else if (Token::Match(tok, "[(,] %var% [,)]"))
|
else if (Token::Match(tok, "[(,] %var% [,)]") && tok->previous()->str() != "*")
|
||||||
variables.use(tok->next()->varId()); // use = read + write
|
variables.use(tok->next()->varId()); // use = read + write
|
||||||
|
|
||||||
else if (Token::Match(tok, " %var% ."))
|
else if (Token::Match(tok, " %var% ."))
|
||||||
|
|
|
@ -81,6 +81,7 @@ private:
|
||||||
TEST_CASE(localvar16); // ticket #1709
|
TEST_CASE(localvar16); // ticket #1709
|
||||||
TEST_CASE(localvar17); // ticket #1720
|
TEST_CASE(localvar17); // ticket #1720
|
||||||
TEST_CASE(localvar18); // ticket #1723
|
TEST_CASE(localvar18); // ticket #1723
|
||||||
|
TEST_CASE(localvar19); // ticket #1776
|
||||||
TEST_CASE(localvaralias1);
|
TEST_CASE(localvaralias1);
|
||||||
TEST_CASE(localvaralias2); // ticket #1637
|
TEST_CASE(localvaralias2); // ticket #1637
|
||||||
TEST_CASE(localvaralias3); // ticket #1639
|
TEST_CASE(localvaralias3); // ticket #1639
|
||||||
|
@ -1173,6 +1174,17 @@ private:
|
||||||
ASSERT_EQUALS(std::string(""), errout.str());
|
ASSERT_EQUALS(std::string(""), errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void localvar19() // ticket #1776
|
||||||
|
{
|
||||||
|
functionVariableUsage("void foo() {\n"
|
||||||
|
" int a[10];\n"
|
||||||
|
" int c;\n"
|
||||||
|
" c = *(a);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS(std::string("[test.cpp:2]: (style) Variable 'a' is not assigned a value\n"
|
||||||
|
"[test.cpp:3]: (style) Variable 'c' is assigned a value that is never used\n"), errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void localvaralias1()
|
void localvaralias1()
|
||||||
{
|
{
|
||||||
functionVariableUsage("void foo()\n"
|
functionVariableUsage("void foo()\n"
|
||||||
|
|
Loading…
Reference in New Issue