Fixed #4022 (false positive: (style) Variable 'sort_entry' is assigned a value that is never used)
This commit is contained in:
parent
5ba2a300af
commit
1769240e15
|
@ -547,13 +547,13 @@ static const Token* doAssignment(Variables &variables, const Token *tok, bool de
|
|||
else
|
||||
variables.read(varid2, tok);
|
||||
} else {
|
||||
variables.read(varid2, tok);
|
||||
variables.readAll(varid2, tok);
|
||||
}
|
||||
}
|
||||
} else if (var1->_type == Variables::reference) {
|
||||
variables.alias(varid1, varid2, true);
|
||||
} else {
|
||||
if (var2->_type == Variables::pointer && tok->strAt(1) == "[")
|
||||
if ((var2->_type == Variables::pointer || var2->_type == Variables::pointerArray) && tok->strAt(1) == "[")
|
||||
variables.readAliases(varid2, tok);
|
||||
|
||||
variables.read(varid2, tok);
|
||||
|
|
|
@ -2156,6 +2156,24 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Variable 'a' is not assigned a value.\n", errout.str());
|
||||
|
||||
functionVariableUsage("void foo() {\n" // #4022 - FP (a is assigned a value that is never used)
|
||||
" int a[2], *b[2];\n"
|
||||
" a[0] = 123;\n"
|
||||
" b[0] = &a[0];\n"
|
||||
" int *d = b[0];\n"
|
||||
" return *d;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("void foo() {\n" // #4022 - FP (a is assigned a value that is never used)
|
||||
" entry a[2], *b[2];\n"
|
||||
" a[0].value = 123;\n"
|
||||
" b[0] = &a[0];\n"
|
||||
" int d = b[0].value;\n"
|
||||
" return d;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("struct S { char c[100]; };\n"
|
||||
"void foo()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue