Fixed #4493 (FP: uninit struct member (struct is assigned))

This commit is contained in:
Daniel Marjamäki 2013-01-17 17:01:04 +01:00
parent b1eec7c6b7
commit 93fb6b0c6a
2 changed files with 11 additions and 0 deletions

View File

@ -1347,6 +1347,8 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok,
return true;
else if (Token::Match(tok->previous(), "[(,] %var% [,)]") && isVariableUsage(scope, tok, var.isPointer()))
uninitvarError(tok, tok->str() + "." + membervar->name());
else
return true;
} else {
// Use variable
if (!suppressErrors && isVariableUsage(scope, tok, var.isPointer()))

View File

@ -2572,6 +2572,15 @@ private:
" do_something(ab);\n"
"}\n", "test.c", true);
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());
}
};