Fixed #889 (false positive: uninitialized variable)
This commit is contained in:
parent
3e4dd22eed
commit
4abbe9ffd4
|
@ -1287,11 +1287,14 @@ static const Token *uninitvar_checkscope(const Token *tok, const unsigned int va
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "%varid% =", varid))
|
if (Token::Match(tok, "%varid%", varid))
|
||||||
|
{
|
||||||
|
if (Token::simpleMatch(tok->previous(), ">>") || Token::simpleMatch(tok->next(), "="))
|
||||||
{
|
{
|
||||||
init = true;
|
init = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "%var% ("))
|
if (Token::Match(tok, "%var% ("))
|
||||||
{
|
{
|
||||||
|
|
|
@ -973,6 +973,14 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("int a()\n"
|
||||||
|
"{\n"
|
||||||
|
" int ret;\n"
|
||||||
|
" std::cin >> ret;\n"
|
||||||
|
" return ret;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// if..
|
// if..
|
||||||
checkUninitVar("static void foo()\n"
|
checkUninitVar("static void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue