From a7da65a40b4b94c5967b0bfb7a8a34291c321a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 31 May 2013 15:20:58 +0200 Subject: [PATCH] Fixed #4618 (Unmatched suppression: don't show this information message unless --enable=information or --check-cfg is used) --- cli/cppcheckexecutor.cpp | 6 +++--- lib/cppcheck.cpp | 2 +- test/testsuppressions.cpp | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 20726ca54..fa4f31a47 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -191,10 +191,10 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) returnValue = executor.check(); } - if (!settings.checkConfiguration) { - if (!settings._errorsOnly) - reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions()); + if (settings.isEnabled("information") || settings.checkConfiguration) + reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions()); + if (!settings.checkConfiguration) { cppCheck.tooManyConfigsError("",0U); if (settings.isEnabled("missingInclude") && Preprocessor::missingIncludeFlag) { diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9d8b41bed..052728df5 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -215,7 +215,7 @@ unsigned int CppCheck::processFile(const std::string& filename) internalError(filename, e.errorMessage); } - if (!_settings._errorsOnly) + if (_settings.isEnabled("information") || _settings.checkConfiguration) reportUnmatchedSuppressions(_settings.nomsg.getUnmatchedLocalSuppressions(filename)); _errorList.clear(); diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index e98d5e513..2a1452a2f 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -121,6 +121,7 @@ private: CppCheck cppCheck(*this, true); Settings& settings = cppCheck.settings(); settings._inlineSuppressions = true; + settings.addEnabled("information"); if (!suppression.empty()) { std::string r = settings.nomsg.addSuppressionLine(suppression); ASSERT_EQUALS("", r); @@ -141,6 +142,7 @@ private: Settings settings; settings._jobs = 1; settings._inlineSuppressions = true; + settings.addEnabled("information"); if (!suppression.empty()) { std::string r = settings.nomsg.addSuppressionLine(suppression); ASSERT_EQUALS("", r); @@ -162,6 +164,7 @@ private: CppCheck cppCheck(*this, true); Settings& settings = cppCheck.settings(); settings._inlineSuppressions = true; + settings.addEnabled("information"); if (!suppression.empty()) settings.nomsg.addSuppressionLine(suppression);