From 132ae52428cce955ab3a31dcf1914b69dc82910d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 7 Feb 2023 21:58:44 +0100 Subject: [PATCH] Don't show checkLibraryFunction warning for types with unusedvar configuration (#4765) --- lib/checkfunctions.cpp | 3 +++ test/testfunctions.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 37ebca53e..a521f14b4 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -637,6 +637,9 @@ void CheckFunctions::checkLibraryMatchFunctions() if (mSettings->library.podtype(tok->expressionString())) continue; + if (mSettings->library.getTypeCheck("unusedvar", functionName) != Library::TypeCheck::def) + continue; + const Token* start = tok; while (Token::Match(start->tokAt(-2), "%name% ::")) start = start->tokAt(-2); diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp index ffacc665a..a79715dfd 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1957,6 +1957,11 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + check("auto f() {\n" + " return std::runtime_error(\"abc\");\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + settings = settings_old; }