Fixed #1880 (false positive: Uninitialized array (initialized in subfunction))

This commit is contained in:
Daniel Marjamäki 2010-07-19 10:03:54 +02:00
parent 37b37218cf
commit bbf2c6c6e6
2 changed files with 17 additions and 1 deletions

View File

@ -3395,6 +3395,22 @@ private:
// it is possible that the variable is initialized here // it is possible that the variable is initialized here
if (Token::Match(tok2->previous(), "[(,] %var% [,)]")) if (Token::Match(tok2->previous(), "[(,] %var% [,)]"))
bailouts.insert(tok2->varId()); bailouts.insert(tok2->varId());
// array initialization..
if (Token::Match(tok2->previous(), "[,(] %var% +"))
{
// if var is array, bailout
for (std::list<ExecutionPath *>::const_iterator it = checks.begin(); it != checks.end(); ++it)
{
if ((*it)->varId == tok2->varId())
{
const CheckUninitVar *c = dynamic_cast<const CheckUninitVar *>(*it);
if (c && c->array)
bailouts.insert(tok2->varId());
break;
}
}
}
} }
} }

View File

@ -1930,7 +1930,7 @@ private:
" y + 1 );\n" " y + 1 );\n"
" s = y[0]*y[1];\n" " s = y[0]*y[1];\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
// alloc.. // alloc..