Fixed #4020 (false positive: (style) Variable 'dst' is assigned a value that is never used)
This commit is contained in:
parent
4fb464982c
commit
f133c9e8ec
|
@ -356,8 +356,11 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
|
|||
if (var1) {
|
||||
// jump behind '='
|
||||
tok = tok->next();
|
||||
while (tok->str() != "=")
|
||||
while (tok->str() != "=") {
|
||||
if (tok->varId())
|
||||
variables.read(tok->varId());
|
||||
tok = tok->next();
|
||||
}
|
||||
tok = tok->next();
|
||||
|
||||
if (Token::Match(tok, "&| %var%") ||
|
||||
|
@ -479,6 +482,8 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
|
|||
variables.readAliases(varid2);
|
||||
else
|
||||
variables.read(varid2);
|
||||
} else {
|
||||
variables.read(varid2);
|
||||
}
|
||||
}
|
||||
} else if (var1->_type == Variables::reference) {
|
||||
|
|
|
@ -90,6 +90,7 @@ private:
|
|||
TEST_CASE(localvar42); // ticket #3603
|
||||
TEST_CASE(localvar43); // ticket #3742
|
||||
TEST_CASE(localvar44); // ticket #3602
|
||||
TEST_CASE(localvar45); // ticket #4020
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
TEST_CASE(localvaralias3); // ticket #1639
|
||||
|
@ -1519,6 +1520,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar45() { // #4020 - FP
|
||||
functionVariableUsage("void func() {\n"
|
||||
" int *sp_mem[2] = { 0x00, 0x00 };\n"
|
||||
" int src = 1, dst = 2;\n"
|
||||
" sp_mem[(dst + i)][3] = src;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1() {
|
||||
functionVariableUsage("void foo()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue