diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index c85354e58..9918e3709 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -160,6 +160,18 @@ void CheckFunctions::checkIgnoredReturnValue() if (Token::Match(tok, "%var%|(|, {")) tok = tok->linkAt(1); + if (Token::Match(tok->previous(), "%name% (")) { + bool semicolon = false; + for (const Token *tok2 = tok->tokAt(2); tok2 && tok2->str() != ")"; tok2 = tok2->next()) { + if (tok2->str() == ";") + semicolon = true; + else if (Token::Match(tok2, "[({]")) + tok2 = tok2->link(); + } + if (semicolon) + tok = tok->link(); + } + if (tok->varId() || !Token::Match(tok, "%name% (")) continue; diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 95ef04f00..12a81abe2 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -912,6 +912,12 @@ private: " int x({mystrcmp(a,b)});\n" "}", "test.cpp", &settings2); ASSERT_EQUALS("", errout.str()); + + // #7979 - code is not well configured + check("void foo() {\n" + " DEBUG(x(); mystrcmp(a,b););\n" + "}", "test.cpp", &settings2); + ASSERT_EQUALS("", errout.str()); } };