Fixed
This commit is contained in:
parent
2cbda0cfe4
commit
d866c174cf
|
@ -1300,8 +1300,11 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "%varid%", varid))
|
if (tok->varId() == varid)
|
||||||
{
|
{
|
||||||
|
if (pointer && Token::Match(tok->tokAt(-2), "[;{}] *"))
|
||||||
|
return tok;
|
||||||
|
|
||||||
if (Token::simpleMatch(tok->previous(), ">>") || Token::simpleMatch(tok->next(), "="))
|
if (Token::simpleMatch(tok->previous(), ">>") || Token::simpleMatch(tok->next(), "="))
|
||||||
{
|
{
|
||||||
init = true;
|
init = true;
|
||||||
|
|
|
@ -973,6 +973,13 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("static void foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" int *p;\n"
|
||||||
|
" *p = 135;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
|
||||||
|
|
||||||
checkUninitVar("static void foo()\n"
|
checkUninitVar("static void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" Foo p;\n"
|
" Foo p;\n"
|
||||||
|
|
Loading…
Reference in New Issue