Skip to content

Commit d1e1f95

Browse files
Don't show checkLibraryNoReturn for functions with visible declaration (#11523, #11190) (#4809)
1 parent 103ff90 commit d1e1f95

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7176,7 +7176,7 @@ bool Tokenizer::isScopeNoReturn(const Token *endScopeToken, bool *unknown) const
71767176
bool warn = true;
71777177
if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) {
71787178
const Token * const ftok = endScopeToken->linkAt(-2)->previous();
7179-
if (ftok && (ftok->type() || (ftok->function() && ftok->function()->hasBody()))) // constructor call
7179+
if (ftok && (ftok->type() || ftok->function())) // constructor call
71807180
warn = false;
71817181
}
71827182

test/testleakautovar.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,12 @@ class TestLeakAutoVar : public TestFixture {
24022402
ASSERT_EQUALS("[test.c:3]: (information) --check-library: Function x() should have <noreturn> configuration\n"
24032403
"[test.c:4]: (information) --check-library: Function x() should have <use>/<leak-ignore> configuration\n",
24042404
errout.str());
2405+
2406+
check("void cb();\n" // #11190, #11523
2407+
"void f() {\n"
2408+
" cb();\n"
2409+
"}\n");
2410+
ASSERT_EQUALS("", errout.str());
24052411
}
24062412

24072413
void configuration2() {

0 commit comments

Comments
 (0)