Fixed false positive ignoredReturnValue on unknown member function log() (#6197)

This commit is contained in:
PKEuS 2014-09-29 19:54:50 +02:00
parent a7c870bdc8
commit 374ea8f039
3 changed files with 8 additions and 2 deletions

View File

@ -320,7 +320,7 @@
<leak-ignore/> <leak-ignore/>
<arg nr="1"><not-uninit/></arg> <arg nr="1"><not-uninit/></arg>
</function> </function>
<function name="log"><use-retval/><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/></arg></function> <function name="log"><!--<use-retval/>--><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/></arg></function>
<function name="log10"><use-retval/><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/></arg></function> <function name="log10"><use-retval/><noreturn>false</noreturn><leak-ignore/><arg nr="1"><not-uninit/></arg></function>
<function name="longjmp"> <function name="longjmp">
<noreturn>false</noreturn> <noreturn>false</noreturn>

View File

@ -2754,7 +2754,7 @@ void CheckOther::checkReturnIgnoredReturnValue()
for (std::size_t i = 0; i < functions; ++i) { for (std::size_t i = 0; i < functions; ++i) {
const Scope * scope = symbolDatabase->functionScopes[i]; const Scope * scope = symbolDatabase->functionScopes[i];
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) { for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
if (tok->varId() || !Token::Match(tok, "%var% (")) if (tok->varId() || !Token::Match(tok, "%var% (") || tok->strAt(-1) == ".")
continue; continue;
if (!tok->next()->astParent() && _settings->library.useretval.find(tok->str()) != _settings->library.useretval.end()) if (!tok->next()->astParent() && _settings->library.useretval.find(tok->str()) != _settings->library.useretval.end())

View File

@ -6285,6 +6285,12 @@ private:
" std::ofstream log(logfile.c_str(), std::ios::out);\n" " std::ofstream log(logfile.c_str(), std::ios::out);\n"
"}", "test.cpp", false, false, false, true, &settings_std); "}", "test.cpp", false, false, false, true, &settings_std);
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// #6197
check("void foo() {\n"
" return strcmp(a, b);\n"
"}", "test.cpp", false, false, false, true, &settings_std);
ASSERT_EQUALS("", errout.str());
} }
}; };