Fixed #876 (false positive: uninitialized variable)

This commit is contained in:
Daniel Marjamäki 2009-10-31 10:30:32 +01:00
parent 45df223bfb
commit 266291baf4
2 changed files with 11 additions and 0 deletions

View File

@ -1352,6 +1352,10 @@ void CheckOther::uninitvar()
// if it's a pointer, dereferencing is forbidden
const bool pointer(tok->strAt(2) == std::string("*"));
// classes are initialized by their constructors
if (!pointer && !tok->next()->isStandardType())
continue;
// goto the variable
tok = tok->tokAt(2);
if (tok->str() == "*")

View File

@ -957,6 +957,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("A a()\n"
"{\n"
" A ret;\n"
" return ret;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// if..
checkUninitVar("static void foo()\n"
"{\n"