Fixed #3890 (False positive Uninitialized variable on returning default value on a class member)

This commit is contained in:
Daniel Marjamäki 2012-06-19 20:04:10 +02:00
parent 14591b3211
commit ce5c38f52c
2 changed files with 10 additions and 1 deletions

View File

@ -1054,9 +1054,10 @@ void CheckUninitVar::checkScope(const Scope* scope)
bool stdtype = false;
const Token* tok = i->typeStartToken();
for (; tok->str() != ";"; tok = tok->next())
for (; tok->str() != ";" && tok->str() != "<"; tok = tok->next()) {
if (tok->isStandardType())
stdtype = true;
}
if (stdtype || i->isPointer())
checkScopeForVariable(tok, *i, NULL);

View File

@ -2150,6 +2150,14 @@ private:
" int a, a2, a2*x; if () ;\n"
" )\n"
"}\n");
// Ticket #3890 - False positive for std::map
checkUninitVar2("void f() {\n"
" std::map<int,bool> x;\n"
" return x;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// #3869 - reference variable