diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index eda959f27..15af853aa 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7775,7 +7775,7 @@ bool Tokenizer::isScopeNoReturn(const Token *endScopeToken, bool *unknown) const bool warn = true; if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) { const Token * const ftok = endScopeToken->linkAt(-2)->previous(); - if (ftok && (ftok->type() || ftok->function())) // constructor call + if (ftok && (ftok->type() || ftok->function() || ftok->variable())) // constructor call warn = false; } diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 82da49a40..1ddcf20bf 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -2652,12 +2652,20 @@ private: ASSERT_EQUALS("[test.cpp:5]: (error) Resource leak: file\n", errout.str()); } - void configuration6() { // #11198 - check("void f() {}\n" + void configuration6() { + check("void f() {}\n" // #11198 "void g() {\n" " f();\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(std::function cb) {\n" // #11189 + " cb();\n" + "}\n" + "void g(void (*cb)()) {\n" + " cb();\n" + "}\n", /*cpp*/ true); + ASSERT_EQUALS("", errout.str()); } void ptrptr() {