Fixed #1156 ([False positive] Uninitialized variable - class member in constructor)

This commit is contained in:
Daniel Marjamäki 2009-12-28 12:51:28 +01:00
parent 6fd74dce47
commit 9aca2e7680
2 changed files with 13 additions and 0 deletions

View File

@ -1375,6 +1375,8 @@ private:
static void dealloc_pointer(bool &foundError, std::list<ExecutionPath *> &checks, const Token *tok) static void dealloc_pointer(bool &foundError, std::list<ExecutionPath *> &checks, const Token *tok)
{ {
const unsigned int varid(tok->varId()); const unsigned int varid(tok->varId());
if (!varid)
return;
std::list<ExecutionPath *>::const_iterator it; std::list<ExecutionPath *>::const_iterator it;
for (it = checks.begin(); it != checks.end(); ++it) for (it = checks.begin(); it != checks.end(); ++it)

View File

@ -1094,6 +1094,17 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("class Fred {\n"
"public:\n"
" FILE *f;\n"
" ~Fred();\n"
"}\n"
"Fred::~Fred()\n"
"{\n"
" fclose(f);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// goto.. // goto..
checkUninitVar("void foo(int x)\n" checkUninitVar("void foo(int x)\n"
"{\n" "{\n"