Fixed #1894 (unreadVariable false positive with const references)
This commit is contained in:
parent
050011d287
commit
ed4f1164a1
|
@ -913,6 +913,9 @@ static int doAssignment(Variables &variables, const Token *tok, bool dereference
|
|||
unsigned int varid2;
|
||||
bool addressOf = false;
|
||||
|
||||
if (Token::Match(tok->tokAt(start), "%var% ."))
|
||||
variables.use(tok->tokAt(start)->varId()); // use = read + write
|
||||
|
||||
// check for C style cast
|
||||
if (tok->tokAt(start)->str() == "(")
|
||||
{
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
TEST_CASE(localvar23); // ticket #1808
|
||||
TEST_CASE(localvar24); // ticket #1803
|
||||
TEST_CASE(localvar25); // ticket #1729
|
||||
TEST_CASE(localvar26); // ticket #1894
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
TEST_CASE(localvaralias3); // ticket #1639
|
||||
|
@ -1246,6 +1247,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar26() // ticket #1894
|
||||
{
|
||||
functionVariableUsage("int main() {\n"
|
||||
" const Fred &fred = getfred();\n"
|
||||
" int *p = fred.x();\n"
|
||||
" *p = 0;"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1()
|
||||
{
|
||||
functionVariableUsage("void foo()\n"
|
||||
|
|
Loading…
Reference in New Issue