Fix noreturn FP with while() (#4429)

* Fix checkLibraryFunction FPs

* Fix FP with fclose()

* Format

* Fix FP with reinterpret_cast

* Fix noreturn FP with while()
This commit is contained in:
chrchr-github 2022-09-04 10:26:31 +02:00 committed by GitHub
parent 0f5d2a31b3
commit 31118fdce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -1122,6 +1122,8 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const
return false; return false;
} }
if (Token::Match(start,"[;{}]") && Token::Match(funcname, "%name% )| (")) { if (Token::Match(start,"[;{}]") && Token::Match(funcname, "%name% )| (")) {
if (funcname->isKeyword())
return false;
if (funcname->str() == "exit") if (funcname->str() == "exit")
return true; return true;
if (!isnotnoreturn(funcname)) { if (!isnotnoreturn(funcname)) {

View File

@ -84,6 +84,7 @@ private:
TEST_CASE(uninitvar_cpp11ArrayInit); // #7010 TEST_CASE(uninitvar_cpp11ArrayInit); // #7010
TEST_CASE(uninitvar_rangeBasedFor); // #7078 TEST_CASE(uninitvar_rangeBasedFor); // #7078
TEST_CASE(uninitvar_static); // #8734 TEST_CASE(uninitvar_static); // #8734
TEST_CASE(uninitvar_configuration);
TEST_CASE(checkExpr); TEST_CASE(checkExpr);
TEST_CASE(trac_4871); TEST_CASE(trac_4871);
TEST_CASE(syntax_error); // Ticket #5073 TEST_CASE(syntax_error); // Ticket #5073
@ -4598,6 +4599,23 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void uninitvar_configuration() {
const auto oldSettings = settings;
settings.severity.enable(Severity::information);
settings.checkLibrary = true;
checkUninitVar("int f() {\n"
" int i, j;\n"
" do {\n"
" i = 0;\n"
" return i;\n"
" } while (0);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
settings = oldSettings;
}
void checkExpr() { void checkExpr() {
checkUninitVar("struct AB { int a; int b; };\n" checkUninitVar("struct AB { int a; int b; };\n"
"void f() {\n" "void f() {\n"