Fixed #893 (False Positive: Uninitialized variable b in a[0] = b[0] = '\0';)

This commit is contained in:
Daniel Marjamäki 2009-11-03 21:02:16 +01:00
parent 68f63fdd75
commit c3dff9a6d3
2 changed files with 17 additions and 0 deletions

View File

@ -1294,6 +1294,16 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
init = true;
return 0;
}
if (Token::simpleMatch(tok->next(), "["))
{
const Token *tok2 = Token::findmatch(tok, "]");
if (Token::simpleMatch(tok2 ? tok2->next() : 0, "="))
{
init = true;
return 0;
}
}
}
if (Token::Match(tok, "%var% ("))

View File

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