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