diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 3d2f2d593..5c132e734 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -395,11 +395,7 @@ static const Token *checkMissingReturnScope(const Token *tok, const Library &lib if (tok->str() == "goto" && !isForwardJump(tok)) return nullptr; if (Token::Match(tok, "%name% (") && !library.isnotnoreturn(tok)) { - const Token *start = tok; - while (Token::Match(start->tokAt(-2), "%name% :: %name%")) - start = start->tokAt(-2); - if (Token::Match(start->previous(), "[;{}] %name% ::|(")) - return nullptr; + return nullptr; } if (Token::Match(tok, "[;{}] %name% :")) return tok; diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index f0291e292..427194eac 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1741,6 +1741,16 @@ private: check("template typename std::enable_if{}>::type f(T) {}"); ASSERT_EQUALS("", errout.str()); + + check("struct S {\n" + " [[noreturn]] void f();\n" + " int g() { this->f(); }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + + check("struct S { [[noreturn]] void f(); };\n" + "int g(S& s) { s.f(); }\n"); + ASSERT_EQUALS("", errout.str()); } // NRVO check