Fixed #4899 (False positive on unused variable)
This commit is contained in:
parent
05af4f82ce
commit
3b8e9f5a2a
|
@ -462,6 +462,8 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
|
|||
addressOf = true;
|
||||
tok = tok->next();
|
||||
}
|
||||
} else if (Token::Match(tok, "%cop% %var%")) {
|
||||
variables.read(tok->next()->varId(), tok);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ private:
|
|||
TEST_CASE(localvar43); // ticket #3742
|
||||
TEST_CASE(localvar44); // ticket #3602
|
||||
TEST_CASE(localvar45); // ticket #4020
|
||||
TEST_CASE(localvar46); // ticket #4899
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
TEST_CASE(localvaralias3); // ticket #1639
|
||||
|
@ -1821,6 +1822,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar46() { // #4899 - FP
|
||||
functionVariableUsage("int func() {\n"
|
||||
" int a = 123;\n"
|
||||
" int b = (short)-a;;\n"
|
||||
" return b;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1() {
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue