Skip to content

Commit 19faaee

Browse files
Fix #13718 "bailout: possible noreturn scope" reported with unused cast in always returning scope (#7905)
1 parent f974ce6 commit 19faaee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/astutils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ static bool hasNoreturnFunction(const Token* tok, const Library& library, const
22032203
{
22042204
if (!tok)
22052205
return false;
2206-
const Token* ftok = tok->str() == "(" ? tok->previous() : nullptr;
2206+
const Token* ftok = (tok->str() == "(" && !tok->isCast()) ? tok->previous() : nullptr;
22072207
while (Token::simpleMatch(ftok, "("))
22082208
ftok = ftok->astOperand1();
22092209
if (ftok) {

test/testvalueflow.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class TestValueFlow : public TestFixture {
172172

173173
mNewTemplate = false;
174174
TEST_CASE(valueFlowBailoutIncompleteVar);
175+
TEST_CASE(valueFlowBailoutNoreturn);
175176
mNewTemplate = true;
176177

177178
TEST_CASE(performanceIfCount);
@@ -9077,6 +9078,16 @@ class TestValueFlow : public TestFixture {
90779078
errout_str());
90789079
}
90799080

9081+
void valueFlowBailoutNoreturn() { // #13718
9082+
bailout(
9083+
"void f(const int* p) {\n"
9084+
" if (p)\n"
9085+
" (void)*p;\n"
9086+
"}\n"
9087+
);
9088+
ASSERT_EQUALS_WITHOUT_LINENUMBERS("", errout_str());
9089+
}
9090+
90809091
void performanceIfCount() {
90819092
/*const*/ Settings s(settings);
90829093
s.vfOptions.maxIfCount = 1;

0 commit comments

Comments
 (0)