Fixed #876 (false positive: uninitialized variable)
This commit is contained in:
parent
45df223bfb
commit
266291baf4
|
@ -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() == "*")
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue