diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index c5fb02126..5ee25511d 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -373,6 +373,7 @@ void Suppressions::dump(std::ostream & out) const std::list Suppressions::getUnmatchedLocalSuppressions(const std::string &file, const bool unusedFunctionChecking) const { + std::string tmpFile = Path::simplifyPath(file); std::list result; for (const Suppression &s : mSuppressions) { if (s.matched) @@ -381,7 +382,7 @@ std::list Suppressions::getUnmatchedLocalSuppressions continue; if (!unusedFunctionChecking && s.errorId == "unusedFunction") continue; - if (file.empty() || !s.isLocal() || s.fileName != file) + if (tmpFile.empty() || !s.isLocal() || s.fileName != tmpFile) continue; result.push_back(s); } diff --git a/test/cli/test-inline-suppress.py b/test/cli/test-inline-suppress.py index c94c493af..579748997 100644 --- a/test/cli/test-inline-suppress.py +++ b/test/cli/test-inline-suppress.py @@ -19,3 +19,8 @@ def test_unmatched_suppression(): ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', 'proj-inline-suppress/2.c']) assert ret == 1 assert 'Unmatched suppression: some_warning_id' in stderr + +def test_unmatched_suppression_path_with_extra_stuf(): + ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', './proj-inline-suppress/2.c']) + assert ret == 1 + assert 'Unmatched suppression: some_warning_id' in stderr