diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 421ab3fc996..f76e512a3b9 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2203,7 +2203,7 @@ static bool hasNoreturnFunction(const Token* tok, const Library& library, const { if (!tok) return false; - const Token* ftok = tok->str() == "(" ? tok->previous() : nullptr; + const Token* ftok = (tok->str() == "(" && !tok->isCast()) ? tok->previous() : nullptr; while (Token::simpleMatch(ftok, "(")) ftok = ftok->astOperand1(); if (ftok) { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 5046f88c560..0285e2dea2b 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -172,6 +172,7 @@ class TestValueFlow : public TestFixture { mNewTemplate = false; TEST_CASE(valueFlowBailoutIncompleteVar); + TEST_CASE(valueFlowBailoutNoreturn); mNewTemplate = true; TEST_CASE(performanceIfCount); @@ -9077,6 +9078,16 @@ class TestValueFlow : public TestFixture { errout_str()); } + void valueFlowBailoutNoreturn() { // #13718 + bailout( + "void f(const int* p) {\n" + " if (p)\n" + " (void)*p;\n" + "}\n" + ); + ASSERT_EQUALS_WITHOUT_LINENUMBERS("", errout_str()); + } + void performanceIfCount() { /*const*/ Settings s(settings); s.vfOptions.maxIfCount = 1;