Fixed #893 (False Positive: Uninitialized variable b in a[0] = b[0] = '\0';)
This commit is contained in:
parent
68f63fdd75
commit
c3dff9a6d3
|
@ -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% ("))
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue