Fixed #2535 (false positive: (style) Variable 'A' is not assigned a value)
This commit is contained in:
parent
301f83767e
commit
5175e4ff3f
|
@ -1912,8 +1912,6 @@ void CheckOther::functionVariableUsage()
|
||||||
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% >>"))
|
||||||
variables.use(tok->next()->varId()); // use = read + write
|
variables.use(tok->next()->varId()); // use = read + write
|
||||||
else if (Token::Match(tok, "[{,] %var% [,}]"))
|
|
||||||
variables.read(tok->next()->varId());
|
|
||||||
|
|
||||||
// function parameter
|
// function parameter
|
||||||
else if (Token::Match(tok, "[(,] %var% ["))
|
else if (Token::Match(tok, "[(,] %var% ["))
|
||||||
|
@ -1932,6 +1930,9 @@ void CheckOther::functionVariableUsage()
|
||||||
variables.read(tok->tokAt(2)->varId());
|
variables.read(tok->tokAt(2)->varId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (Token::Match(tok, "[{,] %var% [,}]"))
|
||||||
|
variables.read(tok->next()->varId());
|
||||||
|
|
||||||
else if (Token::Match(tok, "%var% ."))
|
else if (Token::Match(tok, "%var% ."))
|
||||||
variables.use(tok->varId()); // use = read + write
|
variables.use(tok->varId()); // use = read + write
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ private:
|
||||||
TEST_CASE(localvar32); // ticket #2330
|
TEST_CASE(localvar32); // ticket #2330
|
||||||
TEST_CASE(localvar33); // ticket #2346
|
TEST_CASE(localvar33); // ticket #2346
|
||||||
TEST_CASE(localvar34); // ticket #2368
|
TEST_CASE(localvar34); // ticket #2368
|
||||||
|
TEST_CASE(localvar35); // ticket #2535
|
||||||
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
|
||||||
|
@ -1372,6 +1373,15 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void localvar35() // ticket #2535
|
||||||
|
{
|
||||||
|
functionVariableUsage("void f() {\n"
|
||||||
|
" int a, b;\n"
|
||||||
|
" x(1,a,b);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void localvaralias1()
|
void localvaralias1()
|
||||||
{
|
{
|
||||||
functionVariableUsage("void foo()\n"
|
functionVariableUsage("void foo()\n"
|
||||||
|
|
Loading…
Reference in New Issue