Skip to content

Commit fa5fd9c

Browse files
committed
Fixed #11172 (Unmatched suppression for inline suppression even though --suppress=unmatchedSuppression is used)
1 parent 7b549b6 commit fa5fd9c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,11 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck)
870870
}
871871

872872
bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map<std::string, std::size_t> &files, ErrorLogger& errorLogger) {
873+
for (const Suppressions::Suppression& suppression: settings.nomsg.getSuppressions()) {
874+
if (suppression.errorId == "unmatchedSuppression" && suppression.fileName.empty() && suppression.lineNumber == Suppressions::Suppression::NO_LINE)
875+
return false;
876+
}
877+
873878
bool err = false;
874879
if (settings.jointSuppressionReport) {
875880
for (std::map<std::string, std::size_t>::const_iterator i = files.begin(); i != files.end(); ++i) {

test/cli/test-inline-suppress.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ def test_build_dir():
8383
assert ret == 0, stdout
8484
assert len(stderr) == 0
8585

86+
def test_suppress_unmatched_inline_suppression(): # 11172
87+
ret, stdout, stderr = cppcheck(['--enable=all', '--suppress=unmatchedSuppression', '--inline-suppr', 'proj-inline-suppress/2.c'])
88+
assert ret == 0, stdout
89+
assert 'unmatchedSuppression' not in stderr
90+
8691

0 commit comments

Comments
 (0)