From ebe9fc7d04192a397d7679d883378c3a32bfaae7 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Sat, 18 Feb 2023 14:37:23 +0100 Subject: [PATCH] Don't show checkLibraryNoReturn for functions with visible declaration (#11523, #11190) --- 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 db1cfc18ec1..4c8105ec8b5 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 2eab8b86f89..90445747164 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -2402,6 +2402,12 @@ class TestLeakAutoVar : public TestFixture { 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() {