Fixed false positive ignoredReturnValue for variables initialized with constructor syntax (#6194)
This commit is contained in:
parent
798b845ce1
commit
1495a411eb
|
@ -2754,7 +2754,7 @@ void CheckOther::checkReturnIgnoredReturnValue()
|
|||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
||||
if (!Token::Match(tok, "%var% ("))
|
||||
if (tok->varId() || !Token::Match(tok, "%var% ("))
|
||||
continue;
|
||||
|
||||
if (!tok->next()->astParent() && _settings->library.useretval.find(tok->str()) != _settings->library.useretval.end())
|
||||
|
|
|
@ -6279,6 +6279,12 @@ private:
|
|||
" bool b = strcmp(a, b);\n"
|
||||
"}", "test.cpp", false, false, false, true, &settings_std);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #6194
|
||||
check("void foo() {\n"
|
||||
" std::ofstream log(logfile.c_str(), std::ios::out);\n"
|
||||
"}", "test.cpp", false, false, false, true, &settings_std);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue