Skip to content

Commit 319baf8

Browse files
No WRONG_DATA for function pointer with unknown return type (cppcheck-opensource#4893)
1 parent b2263d9 commit 319baf8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/checkfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void CheckFunctions::checkIgnoredReturnValue()
268268
}
269269

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

test/testfunctions.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,11 @@ class TestFunctions : public TestFixture {
19981998
"}\n");
19991999
ASSERT_EQUALS("", errout.str());
20002000

2001+
check("void f() {\n"
2002+
" INT (*g)() = nullptr;\n"
2003+
"}\n");
2004+
ASSERT_EQUALS("", errout.str());
2005+
20012006
settings = settings_old;
20022007
}
20032008

0 commit comments

Comments
 (0)