Fix #11726 "this->" confuses non void return check (#5073)

This commit is contained in:
chrchr-github 2023-05-22 20:23:09 +02:00 committed by GitHub
parent 78182d4773
commit 00733893e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -395,10 +395,6 @@ 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;
}
if (Token::Match(tok, "[;{}] %name% :"))

View File

@ -1741,6 +1741,16 @@ private:
check("template<class T> typename std::enable_if<std::is_same<T, int>{}>::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