No WRONG_DATA for function pointer with unknown return type (#4893)

This commit is contained in:
chrchr-github 2023-03-18 14:52:29 +01:00 committed by GitHub
parent b2263d9475
commit 319baf8d0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -268,7 +268,7 @@ void CheckFunctions::checkIgnoredReturnValue()
}
if ((!tok->function() || !Token::Match(tok->function()->retDef, "void %name%")) &&
!WRONG_DATA(!tok->next()->astOperand1(), tok)) {
tok->next()->astOperand1()) {
const Library::UseRetValType retvalTy = mSettings->library.getUseRetValType(tok);
const bool warn = (tok->function() && tok->function()->isAttributeNodiscard()) || // avoid duplicate warnings for resource-allocating functions
(retvalTy == Library::UseRetValType::DEFAULT && mSettings->library.getAllocFuncInfo(tok) == nullptr);

View File

@ -1998,6 +1998,11 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" INT (*g)() = nullptr;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
settings = settings_old;
}