diff --git a/lib/library.cpp b/lib/library.cpp index f74b000ed..6e17d702a 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -1122,6 +1122,8 @@ bool Library::isScopeNoReturn(const Token *end, std::string *unknownFunc) const return false; } if (Token::Match(start,"[;{}]") && Token::Match(funcname, "%name% )| (")) { + if (funcname->isKeyword()) + return false; if (funcname->str() == "exit") return true; if (!isnotnoreturn(funcname)) { diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index a3255cd6c..87dcdb0b6 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -84,6 +84,7 @@ private: TEST_CASE(uninitvar_cpp11ArrayInit); // #7010 TEST_CASE(uninitvar_rangeBasedFor); // #7078 TEST_CASE(uninitvar_static); // #8734 + TEST_CASE(uninitvar_configuration); TEST_CASE(checkExpr); TEST_CASE(trac_4871); TEST_CASE(syntax_error); // Ticket #5073 @@ -4598,6 +4599,23 @@ private: 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() { checkUninitVar("struct AB { int a; int b; };\n" "void f() {\n"