Fixed #11172 (Unmatched suppression for inline suppression even though --suppress=unmatchedSuppression is used)

This commit is contained in:
Daniel Marjamäki 2022-07-12 22:51:26 +02:00
parent 7b549b622f
commit fa5fd9cae0
2 changed files with 10 additions and 0 deletions

View File

@ -870,6 +870,11 @@ int CppCheckExecutor::check_wrapper(CppCheck& cppcheck)
}
bool CppCheckExecutor::reportSuppressions(const Settings &settings, bool unusedFunctionCheckEnabled, const std::map<std::string, std::size_t> &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<std::string, std::size_t>::const_iterator i = files.begin(); i != files.end(); ++i) {

View File

@ -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