From 374ea8f0390512dcbfd42fe61d9ae0b1a9bb0296 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 29 Sep 2014 19:54:50 +0200 Subject: [PATCH] Fixed false positive ignoredReturnValue on unknown member function log() (#6197) --- cfg/std.cfg | 2 +- lib/checkother.cpp | 2 +- test/testother.cpp | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index 7b74e6335..0e1210348 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -320,7 +320,7 @@ - false + false false false diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 5b6bd17f8..530de74c6 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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 (tok->varId() || !Token::Match(tok, "%var% (")) + if (tok->varId() || !Token::Match(tok, "%var% (") || tok->strAt(-1) == ".") continue; if (!tok->next()->astParent() && _settings->library.useretval.find(tok->str()) != _settings->library.useretval.end()) diff --git a/test/testother.cpp b/test/testother.cpp index 61da1fe93..9c5ddbecc 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6285,6 +6285,12 @@ private: " std::ofstream log(logfile.c_str(), std::ios::out);\n" "}", "test.cpp", false, false, false, true, &settings_std); 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()); } };