Skip to content

Commit a7da65a

Browse files
committed
Fixed cppcheck-opensource#4618 (Unmatched suppression: don't show this information message unless --enable=information or --check-cfg is used)
1 parent 065853a commit a7da65a

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
191191
returnValue = executor.check();
192192
}
193193

194-
if (!settings.checkConfiguration) {
195-
if (!settings._errorsOnly)
196-
reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions());
194+
if (settings.isEnabled("information") || settings.checkConfiguration)
195+
reportUnmatchedSuppressions(settings.nomsg.getUnmatchedGlobalSuppressions());
197196

197+
if (!settings.checkConfiguration) {
198198
cppCheck.tooManyConfigsError("",0U);
199199

200200
if (settings.isEnabled("missingInclude") && Preprocessor::missingIncludeFlag) {

lib/cppcheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ unsigned int CppCheck::processFile(const std::string& filename)
215215
internalError(filename, e.errorMessage);
216216
}
217217

218-
if (!_settings._errorsOnly)
218+
if (_settings.isEnabled("information") || _settings.checkConfiguration)
219219
reportUnmatchedSuppressions(_settings.nomsg.getUnmatchedLocalSuppressions(filename));
220220

221221
_errorList.clear();

test/testsuppressions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class TestSuppressions : public TestFixture {
121121
CppCheck cppCheck(*this, true);
122122
Settings& settings = cppCheck.settings();
123123
settings._inlineSuppressions = true;
124+
settings.addEnabled("information");
124125
if (!suppression.empty()) {
125126
std::string r = settings.nomsg.addSuppressionLine(suppression);
126127
ASSERT_EQUALS("", r);
@@ -141,6 +142,7 @@ class TestSuppressions : public TestFixture {
141142
Settings settings;
142143
settings._jobs = 1;
143144
settings._inlineSuppressions = true;
145+
settings.addEnabled("information");
144146
if (!suppression.empty()) {
145147
std::string r = settings.nomsg.addSuppressionLine(suppression);
146148
ASSERT_EQUALS("", r);
@@ -162,6 +164,7 @@ class TestSuppressions : public TestFixture {
162164
CppCheck cppCheck(*this, true);
163165
Settings& settings = cppCheck.settings();
164166
settings._inlineSuppressions = true;
167+
settings.addEnabled("information");
165168
if (!suppression.empty())
166169
settings.nomsg.addSuppressionLine(suppression);
167170

0 commit comments

Comments
 (0)