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;
|
if (Token::simpleMatch(tok->previous(), ">>") || Token::simpleMatch(tok->next(), "="))
|
||||||
return 0;
|
{
|
||||||
|
init = true;
|
||||||
|
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