Fixed #910 (false positive: uninitialized variable for array)
This commit is contained in:
parent
52eb32eb5b
commit
4b04ed9ad9
|
@ -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;
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue