Fixed #925 (uninitialized deletion not detected)
This commit is contained in:
parent
95c898f37b
commit
469a8e4032
|
@ -1317,6 +1317,12 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok->previous(), "delete") ||
|
||||
Token::simpleMatch(tok->tokAt(-3), "delete [ ]"))
|
||||
{
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "%var% ("))
|
||||
|
|
|
@ -959,6 +959,20 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
|
||||
|
||||
checkUninitVar("static void foo()\n"
|
||||
"{\n"
|
||||
" int *p;\n"
|
||||
" delete p;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
|
||||
|
||||
checkUninitVar("static void foo()\n"
|
||||
"{\n"
|
||||
" int *p;\n"
|
||||
" delete [] p;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
|
||||
|
||||
checkUninitVar("static void foo()\n"
|
||||
"{\n"
|
||||
" Foo p;\n"
|
||||
|
|
Loading…
Reference in New Issue