Merge pull request #5152 from chrchr-github/chr_Fix11189

Partial fix for #11189 checkLibraryNoReturn with std::function parameter
This commit is contained in:
chrchr-github 2023-06-16 23:59:17 +02:00 committed by GitHub
commit 58dd92dd1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -7775,7 +7775,7 @@ bool Tokenizer::isScopeNoReturn(const Token *endScopeToken, bool *unknown) const
bool warn = true; bool warn = true;
if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) { if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) {
const Token * const ftok = endScopeToken->linkAt(-2)->previous(); 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; warn = false;
} }

View File

@ -2652,12 +2652,20 @@ private:
ASSERT_EQUALS("[test.cpp:5]: (error) Resource leak: file\n", errout.str()); ASSERT_EQUALS("[test.cpp:5]: (error) Resource leak: file\n", errout.str());
} }
void configuration6() { // #11198 void configuration6() {
check("void f() {}\n" check("void f() {}\n" // #11198
"void g() {\n" "void g() {\n"
" f();\n" " f();\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void f(std::function<void()> cb) {\n" // #11189
" cb();\n"
"}\n"
"void g(void (*cb)()) {\n"
" cb();\n"
"}\n", /*cpp*/ true);
ASSERT_EQUALS("", errout.str());
} }
void ptrptr() { void ptrptr() {