From d1e1f951dfc37eebdd2618ae460642e4e1d5a3c1 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 24 Feb 2023 06:49:28 +0100 Subject: [PATCH] Don't show checkLibraryNoReturn for functions with visible declaration (#11523, #11190) (#4809) --- lib/tokenize.cpp | 2 +- test/testleakautovar.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index db1cfc18e..4c8105ec8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7176,7 +7176,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() && ftok->function()->hasBody()))) // constructor call + if (ftok && (ftok->type() || ftok->function())) // constructor call warn = false; } diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 2eab8b86f..904457471 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -2402,6 +2402,12 @@ private: ASSERT_EQUALS("[test.c:3]: (information) --check-library: Function x() should have configuration\n" "[test.c:4]: (information) --check-library: Function x() should have / configuration\n", errout.str()); + + check("void cb();\n" // #11190, #11523 + "void f() {\n" + " cb();\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void configuration2() {