No WRONG_DATA for function pointer with unknown return type (#4893)
This commit is contained in:
parent
b2263d9475
commit
319baf8d0f
|
@ -268,7 +268,7 @@ void CheckFunctions::checkIgnoredReturnValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!tok->function() || !Token::Match(tok->function()->retDef, "void %name%")) &&
|
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 Library::UseRetValType retvalTy = mSettings->library.getUseRetValType(tok);
|
||||||
const bool warn = (tok->function() && tok->function()->isAttributeNodiscard()) || // avoid duplicate warnings for resource-allocating functions
|
const bool warn = (tok->function() && tok->function()->isAttributeNodiscard()) || // avoid duplicate warnings for resource-allocating functions
|
||||||
(retvalTy == Library::UseRetValType::DEFAULT && mSettings->library.getAllocFuncInfo(tok) == nullptr);
|
(retvalTy == Library::UseRetValType::DEFAULT && mSettings->library.getAllocFuncInfo(tok) == nullptr);
|
||||||
|
|
|
@ -1998,6 +1998,11 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" INT (*g)() = nullptr;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
settings = settings_old;
|
settings = settings_old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue