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 +