diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 709c263c1..68e29418e 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -204,7 +204,10 @@ void CheckFunctions::checkIgnoredReturnValue() if (tok->varId() || !Token::Match(tok, "%name% (") || tok->isKeyword()) continue; - if (tok->next()->astParent()) + const Token *parent = tok->next()->astParent(); + while (Token::Match(parent, "%cop%")) + parent = parent->astParent(); + if (parent) continue; if (!tok->scope()->isExecutable()) { diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index ca5135ea5..cd44d06a3 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1231,6 +1231,13 @@ private: "}\n" "A g() { return f(1); }"); ASSERT_EQUALS("", errout.str()); + + // #8412 - unused operator result + check("void foo() {\n" + " !mystrcmp(a, b);\n" + "}", "test.cpp", &settings2); + ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of function mystrcmp() is not used.\n", errout.str()); + } void checkIgnoredErrorCode() {