Fixed #9417 (FP uninitvar - member initialized in operator())

This commit is contained in:
Daniel Marjamäki 2019-11-11 15:00:32 +01:00
parent 1daf076d63
commit f5a6aa530d
2 changed files with 10 additions and 1 deletions

View File

@ -948,7 +948,10 @@ void CheckUninitVar::checkRhs(const Token *tok, const Variable &var, Alloc alloc
bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc alloc) const
{
if (alloc == NO_ALLOC && ((Token::Match(vartok->previous(), "return|delete %var% !!=")) || (vartok->strAt(-1) == "]" && vartok->linkAt(-1)->strAt(-1) == "delete")))
if (!pointer && Token::Match(vartok, "%name% ("))
return false;
if (alloc == NO_ALLOC && (Token::Match(vartok->previous(), "return|delete %var% !!=") || (vartok->strAt(-1) == "]" && vartok->linkAt(-1)->strAt(-1) == "delete")))
return true;
// Passing variable to typeof/__alignof__

View File

@ -4124,6 +4124,12 @@ private:
"}");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str());
valueFlowUninit("struct S { int x; };\n" // #9417
"void f() {\n"
" S s;\n"
" return s(1);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
valueFlowUninit("void a() {\n" // asm