Fixed false positives about uninitialized variables

This commit is contained in:
Daniel Marjamäki 2009-12-23 15:01:23 +01:00
parent ef21ba7425
commit b6c320de8a
2 changed files with 9 additions and 0 deletions

View File

@ -1286,6 +1286,8 @@ private:
static void use(bool &foundError, std::list<ExecutionPath *> &checks, const Token *tok, const int mode) static void use(bool &foundError, std::list<ExecutionPath *> &checks, const Token *tok, const int mode)
{ {
const unsigned int varid(tok->varId()); const unsigned int varid(tok->varId());
if (varid == 0)
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

@ -1315,6 +1315,13 @@ private:
" strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));\n" " strcpy(hex, sha1_to_hex(suspect->commit->object.sha1));\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n"
"{\n"
" const std::string s(x());\n"
" strchr(s.c_str(), ',');\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }