Fixed #4600 (False positive Uninitialized struct member when using it as 'out parameter')
This commit is contained in:
parent
653d5242d9
commit
ee435bf885
|
@ -1412,9 +1412,10 @@ bool CheckUninitVar::checkIfForWhileHead(const Token *startparentheses, const Va
|
|||
if (tok->varId() == var.varId()) {
|
||||
if (Token::Match(tok, "%var% . %var%")) {
|
||||
if (tok->strAt(2) == membervar) {
|
||||
if (tok->strAt(3) == "=")
|
||||
if (isMemberVariableAssignment(tok, membervar))
|
||||
return true;
|
||||
else
|
||||
|
||||
if (isMemberVariableUsage(tok, var.isPointer(), membervar))
|
||||
uninitStructMemberError(tok, tok->str() + "." + membervar);
|
||||
}
|
||||
continue;
|
||||
|
|
|
@ -2696,6 +2696,12 @@ private:
|
|||
" for (s.n = 0; s.n <= 10; s.n++) { }\n"
|
||||
"}", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("void test2() {\n"
|
||||
" struct { char type; } s_d;\n"
|
||||
" if (foo(&s_d.type)){}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar2_while() {
|
||||
|
|
Loading…
Reference in New Issue