Fixed #1808 (false positive: uninitialized variable with multiple assignment)

This commit is contained in:
Daniel Marjamäki 2010-06-25 19:39:30 +02:00
parent f3538dd574
commit ad0908cb3f
2 changed files with 16 additions and 0 deletions

View File

@ -2948,6 +2948,15 @@ private:
!Token::Match(tok2->previous(), "&|::") &&
!Token::simpleMatch(tok2->next(), "="))
{
// Multiple assignments..
if (Token::simpleMatch(tok2->next(), "["))
{
const Token * tok3 = tok2;
while (Token::simpleMatch(tok3->next(), "["))
tok3 = tok3->next()->link();
if (Token::simpleMatch(tok3, "] ="))
continue;
}
bool foundError;
if (tok2->previous()->str() == "*" || tok2->next()->str() == "[")
foundError = use_array_or_pointer_data(checks, tok2);

View File

@ -1817,6 +1817,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n"
"{\n"
" char a, b[10];\n"
" a = b[0] = 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n"
"{\n"
" char a[10], b[10];\n"