diff --git a/lib/forwardanalyzer.cpp b/lib/forwardanalyzer.cpp index c38d93155ea..14678fc22a3 100644 --- a/lib/forwardanalyzer.cpp +++ b/lib/forwardanalyzer.cpp @@ -144,7 +144,7 @@ namespace { // If we are in a loop then jump to the end if (out) *out = loopEnds.back(); - } else if (Token::Match(tok, "return|throw")) { + } else if (Token::Match(tok, "return|co_return|throw")) { traverseRecursive(tok->astOperand2(), f, traverseUnknown); traverseRecursive(tok->astOperand1(), f, traverseUnknown); return Break(Analyzer::Terminate::Escape); diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 86b0f4aeeb9..698946b8efa 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -146,6 +146,7 @@ class TestNullPointer : public TestFixture { TEST_CASE(nullpointer106); // #13682 TEST_CASE(nullpointer107); // #13682 (FP/FN cases around guards that depend on the pointer indirectly) TEST_CASE(nullpointer108); + TEST_CASE(nullpointer109); TEST_CASE(nullpointer_addressOf); // address of TEST_CASE(nullpointerSwitch); // #2626 TEST_CASE(nullpointer_cast); // #4692 @@ -3115,6 +3116,18 @@ class TestNullPointer : public TestFixture { ASSERT_EQUALS("[test.cpp:4:10]: (error) Null pointer dereference: r [nullPointer]\n", errout_str()); } + void nullpointer109() + { + check("boost::asio::awaitable test()\n" + "{\n" + " const auto *s = getStr();\n" + " if(!s) co_return int{1};\n" + " std::print(\"{}\",*s);\n" + " co_return int{9};\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); + } + void nullpointer_addressOf() { // address of check("void f() {\n" " struct X *x = 0;\n"