Uninitialized struct member: Fixed false negatives for return statements
This commit is contained in:
parent
d33341a21a
commit
76534ccd1b
|
@ -1321,9 +1321,16 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok,
|
|||
|
||||
while (tok && tok->str() != ";") {
|
||||
// variable is seen..
|
||||
if (tok->varId() == var.varId() && (membervar.empty())) {
|
||||
if (tok->varId() == var.varId()) {
|
||||
if (!membervar.empty()) {
|
||||
if (Token::Match(tok, "%var% . %var% ;|%op%") && tok->strAt(2) == membervar)
|
||||
uninitStructMemberError(tok, tok->str() + "." + membervar);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use variable
|
||||
if (!suppressErrors && isVariableUsage(scope, tok, var.isPointer()))
|
||||
else if (!suppressErrors && isVariableUsage(scope, tok, var.isPointer()))
|
||||
uninitvarError(tok, tok->str());
|
||||
|
||||
else
|
||||
|
|
|
@ -2635,7 +2635,7 @@ private:
|
|||
" ab.a = 0;\n"
|
||||
" return ab.b;\n"
|
||||
"}\n", "test.c", true);
|
||||
TODO_ASSERT_EQUALS("error", "", errout.str());
|
||||
ASSERT_EQUALS("[test.c:5]: (error) Uninitialized struct member: ab.b\n", errout.str());
|
||||
|
||||
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||
"void f(void) {\n"
|
||||
|
|
Loading…
Reference in New Issue