From 319baf8d0f97cb0e9c39354226482fa126cc3584 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Sat, 18 Mar 2023 14:52:29 +0100 Subject: [PATCH] No WRONG_DATA for function pointer with unknown return type (#4893) --- lib/checkfunctions.cpp | 2 +- test/testfunctions.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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; }