From fa5fd9cae0e4e7d2a58008ddb90026d07ebbddbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 12 Jul 2022 22:51:26 +0200 Subject: [PATCH] Fixed #11172 (Unmatched suppression for inline suppression even though --suppress=unmatchedSuppression is used) --- cli/cppcheckexecutor.cpp | 5 +++++ test/cli/test-inline-suppress.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 33b2a6f0b..4d3ee752e 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -870,6 +870,11 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck) } bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map &files, ErrorLogger& errorLogger) { + for (const Suppressions::Suppression& suppression: settings.nomsg.getSuppressions()) { + if (suppression.errorId == "unmatchedSuppression" && suppression.fileName.empty() && suppression.lineNumber == Suppressions::Suppression::NO_LINE) + return false; + } + bool err = false; if (settings.jointSuppressionReport) { for (std::map::const_iterator i = files.begin(); i != files.end(); ++i) { diff --git a/test/cli/test-inline-suppress.py b/test/cli/test-inline-suppress.py index ebd7a4558..0f572f425 100644 --- a/test/cli/test-inline-suppress.py +++ b/test/cli/test-inline-suppress.py @@ -83,4 +83,9 @@ def test_build_dir(): assert ret == 0, stdout assert len(stderr) == 0 +def test_suppress_unmatched_inline_suppression(): # 11172 + ret, stdout, stderr = cppcheck(['--enable=all', '--suppress=unmatchedSuppression', '--inline-suppr', 'proj-inline-suppress/2.c']) + assert ret == 0, stdout + assert 'unmatchedSuppression' not in stderr +