From 304e4487491fda9be97559c8b59381b8e5d5571f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 28 Jul 2022 22:47:15 +0200 Subject: [PATCH] Fix #8476 --check-library reports missing configuration for static_assert (#4314) --- lib/checkleakautovar.cpp | 7 ++++--- test/testleakautovar.cpp | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 575bf7276..a9c0bb14a 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -644,8 +644,7 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken, } // Function call.. - else if (isFunctionCall(ftok)) { - const Token * openingPar = isFunctionCall(ftok); + else if (const Token* openingPar = isFunctionCall(ftok)) { const Library::AllocFunc* af = mSettings->library.getDeallocFuncInfo(ftok); VarInfo::AllocInfo allocation(af ? af->groupId : 0, VarInfo::DEALLOC, ftok); if (allocation.type == 0) @@ -658,7 +657,9 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken, // Handle scopes that might be noreturn if (allocation.status == VarInfo::NOALLOC && Token::simpleMatch(tok, ") ; }")) { - const std::string functionName(mSettings->library.getFunctionName(tok->link()->previous())); + if (ftok->isKeyword()) + continue; + const std::string functionName(mSettings->library.getFunctionName(ftok)); bool unknown = false; if (mTokenizer->isScopeNoReturn(tok->tokAt(2), &unknown)) { if (!unknown) diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index f19c23b23..6f881e87a 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -2401,6 +2401,11 @@ private: " int(i);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f() {\n" + " static_assert(1 == sizeof(char), \"test\");\n" + "}\n", /*cpp*/ true); + ASSERT_EQUALS("", errout.str()); } void ptrptr() {