Fixed #3906 (false positive uninitvar for vector pointer)

This commit is contained in:
Daniel Marjamäki 2012-06-22 16:26:43 +02:00
parent 951da02f89
commit 354406441a
2 changed files with 8 additions and 1 deletions

View File

@ -1058,7 +1058,8 @@ void CheckUninitVar::checkScope(const Scope* scope)
if (tok->isStandardType()) if (tok->isStandardType())
stdtype = true; stdtype = true;
} }
while (tok && tok->str() != ";")
tok = tok->next();
if (stdtype || i->isPointer()) if (stdtype || i->isPointer())
checkScopeForVariable(tok, *i, NULL); checkScopeForVariable(tok, *i, NULL);
} }

View File

@ -2158,6 +2158,12 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Ticket #3906 - False positive for std::vector pointer
checkUninitVar2("void f() {\n"
" std::vector<int> *x = NULL;\n"
" return x;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }
// #3869 - reference variable // #3869 - reference variable