Fixed #910 (false positive: uninitialized variable for array)

This commit is contained in:
Daniel Marjamäki 2009-11-08 07:31:01 +01:00
parent 52eb32eb5b
commit 4b04ed9ad9
2 changed files with 10 additions and 0 deletions

View File

@ -1361,6 +1361,9 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
if (tok->varId() == varid)
{
if (array && !Token::simpleMatch(tok->next(), "["))
continue;
if (Token::simpleMatch(tok->previous(), "return"))
return tok;

View File

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