diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 43646c50d..b8de92aeb 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -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); diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index 9424f3103..e63cf7680 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -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; }