uninitvar: Fixed a FP seen in daca2

This commit is contained in:
Daniel Marjamäki 2016-12-25 22:43:29 +01:00
parent ecc91ba914
commit c8a450c9be
2 changed files with 7 additions and 1 deletions

View File

@ -839,7 +839,8 @@ void CheckUninitVar::checkRhs(const Token *tok, const Variable &var, Alloc alloc
uninitvarError(tok, tok->str(), alloc);
else if (!membervar.empty() && isMemberVariableUsage(tok, var.isPointer(), alloc, membervar))
uninitStructMemberError(tok, tok->str() + "." + membervar);
else if (Token::Match(tok, "%var% ="))
break;
} else if (tok->str() == ";" || (indent==0 && tok->str() == ","))
break;
else if (tok->str() == "(")

View File

@ -969,6 +969,11 @@ private:
"}");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: y\n", errout.str());
checkUninitVar("void foo() {\n" // pidgin-2.11.0/finch/libgnt/gnttree.c
" int x = (x = bar()) ? x : 0;\n"
"}");
ASSERT_EQUALS("", errout.str());
// ; { .. }
checkUninitVar("int foo()\n"
"{\n"