Fixed #4493 (FP: uninit struct member (struct is assigned))
This commit is contained in:
parent
b1eec7c6b7
commit
93fb6b0c6a
|
@ -1347,6 +1347,8 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok,
|
||||||
return true;
|
return true;
|
||||||
else if (Token::Match(tok->previous(), "[(,] %var% [,)]") && isVariableUsage(scope, tok, var.isPointer()))
|
else if (Token::Match(tok->previous(), "[(,] %var% [,)]") && isVariableUsage(scope, tok, var.isPointer()))
|
||||||
uninitvarError(tok, tok->str() + "." + membervar->name());
|
uninitvarError(tok, tok->str() + "." + membervar->name());
|
||||||
|
else
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Use variable
|
// Use variable
|
||||||
if (!suppressErrors && isVariableUsage(scope, tok, var.isPointer()))
|
if (!suppressErrors && isVariableUsage(scope, tok, var.isPointer()))
|
||||||
|
|
|
@ -2572,6 +2572,15 @@ private:
|
||||||
" do_something(ab);\n"
|
" do_something(ab);\n"
|
||||||
"}\n", "test.c", true);
|
"}\n", "test.c", true);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar2("struct AB { int a; int b; };\n"
|
||||||
|
"void do_something(const struct AB ab);\n"
|
||||||
|
"void f(void) {\n"
|
||||||
|
" struct AB ab;\n"
|
||||||
|
" ab = getAB();\n"
|
||||||
|
" do_something(ab);\n"
|
||||||
|
"}\n", "test.c", true);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue