Fix #8476 --check-library reports missing configuration for static_assert (#4314)

This commit is contained in:
chrchr-github 2022-07-28 22:47:15 +02:00 committed by GitHub
parent c340b6ae6c
commit 304e448749
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -644,8 +644,7 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
} }
// Function call.. // Function call..
else if (isFunctionCall(ftok)) { else if (const Token* openingPar = isFunctionCall(ftok)) {
const Token * openingPar = isFunctionCall(ftok);
const Library::AllocFunc* af = mSettings->library.getDeallocFuncInfo(ftok); const Library::AllocFunc* af = mSettings->library.getDeallocFuncInfo(ftok);
VarInfo::AllocInfo allocation(af ? af->groupId : 0, VarInfo::DEALLOC, ftok); VarInfo::AllocInfo allocation(af ? af->groupId : 0, VarInfo::DEALLOC, ftok);
if (allocation.type == 0) if (allocation.type == 0)
@ -658,7 +657,9 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
// Handle scopes that might be noreturn // Handle scopes that might be noreturn
if (allocation.status == VarInfo::NOALLOC && Token::simpleMatch(tok, ") ; }")) { 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; bool unknown = false;
if (mTokenizer->isScopeNoReturn(tok->tokAt(2), &unknown)) { if (mTokenizer->isScopeNoReturn(tok->tokAt(2), &unknown)) {
if (!unknown) if (!unknown)

View File

@ -2401,6 +2401,11 @@ private:
" int(i);\n" " int(i);\n"
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" static_assert(1 == sizeof(char), \"test\");\n"
"}\n", /*cpp*/ true);
ASSERT_EQUALS("", errout.str());
} }
void ptrptr() { void ptrptr() {