From 8ad4f8bc48012d796610857525937f51617038cf Mon Sep 17 00:00:00 2001 From: chrchr Date: Fri, 3 Feb 2023 14:04:57 +0100 Subject: [PATCH] Don't show checkLibraryFunction warning for types with unusedvar configuration --- lib/checkfunctions.cpp | 3 +++ test/testfunctions.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 37ebca53e2d..a521f14b4fb 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 63be8faa4d9..9a447891e35 100644 --- a/test/testfunctions.cpp +++ b/test/testfunctions.cpp @@ -1959,6 +1959,11 @@ class TestFunctions : public TestFixture { "[test.cpp:5]: (information) --check-library: There is no matching configuration for function F::g()\n", errout.str()); + check("auto f() {\n" + " return std::runtime_error(\"abc\");\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + settings = settings_old; }