Fixed #1533 (False positive: Uninitialized variable)
This commit is contained in:
parent
86fabd03b3
commit
c7867af3c5
|
@ -149,6 +149,13 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
|
|||
|
||||
if (Token::Match(tok, "= {"))
|
||||
{
|
||||
// GCC struct initialization.. bail out
|
||||
if (Token::Match(tok->tokAt(2), ". %var% ="))
|
||||
{
|
||||
ExecutionPath::bailOut(checks);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tok = tok->next()->link();
|
||||
if (!tok)
|
||||
{
|
||||
|
|
|
@ -1280,6 +1280,16 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #1533
|
||||
checkUninitVar("char a()\n"
|
||||
"{\n"
|
||||
" char key;\n"
|
||||
" struct A msg = { .buf = {&key} };\n"
|
||||
" init(&msg);\n"
|
||||
" return key;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void foo()\n"
|
||||
"{\n"
|
||||
" char *buf = malloc(100);\n"
|
||||
|
|
Loading…
Reference in New Issue