Fixed #2188 (Does not detect initialization)

This commit is contained in:
Daniel Marjamäki 2010-11-12 16:11:44 +01:00
parent a605bdc8a2
commit 6b489230e8
2 changed files with 9 additions and 1 deletions

View File

@ -673,7 +673,7 @@ private:
bailouts.insert(tok2->varId());
// array initialization..
if (Token::Match(tok2->previous(), "[,(] %var% +"))
if (Token::Match(tok2->previous(), "[,(] %var% [+-]"))
{
// if var is array, bailout
for (std::list<ExecutionPath *>::const_iterator it = checks.begin(); it != checks.end(); ++it)

View File

@ -879,6 +879,14 @@ private:
" s = y[0]*y[1];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n"
"{\n"
" int a[2];\n"
" init(a - 1);\n"
" int b = a[0];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// alloc..