From 00733893e0189bd307966ddcccd43fcac63bfd15 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 22 May 2023 20:23:09 +0200 Subject: [PATCH] Fix #11726 "this->" confuses non void return check (#5073) --- lib/checkfunctions.cpp | 6 +----- test/testfunctions.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) 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