Fixed #4600 (False positive Uninitialized struct member when using it as 'out parameter')

This commit is contained in:
Daniel Marjamki 2013-02-23 15:57:58 +01:00
parent 653d5242d9
commit ee435bf885
2 changed files with 9 additions and 2 deletions

View File

@ -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;

View File

@ -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() {