diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 2eb0ec41a..348b80a50 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -74,6 +74,8 @@ std::string Suppressions::parseFile(std::istream &istr) continue; // Skip comments + if (line.length() > 1 && line[0] == '#') + continue; if (line.length() >= 2 && line[0] == '/' && line[1] == '/') continue; diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 7228887af..9cc443797 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -48,6 +48,7 @@ private: TEST_CASE(suppressionsMultiFile); TEST_CASE(suppressionsPathSeparator); TEST_CASE(suppressionsLine0); + TEST_CASE(suppressionsFileComment); TEST_CASE(inlinesuppress); TEST_CASE(inlinesuppress_symbolname); @@ -411,6 +412,18 @@ private: ASSERT_EQUALS(true, suppressions.isSuppressed(errorMessage("syntaxError", "test.cpp", 0))); } + void suppressionsFileComment() { + std::istringstream file1("# comment\nabc"); + Suppressions suppressions1; + suppressions1.parseFile(file1); + ASSERT_EQUALS(true, suppressions1.isSuppressed(errorMessage("abc", "test.cpp", 123))); + + std::istringstream file2("// comment\nabc"); + Suppressions suppressions2; + suppressions2.parseFile(file2); + ASSERT_EQUALS(true, suppressions2.isSuppressed(errorMessage("abc", "test.cpp", 123))); + } + void inlinesuppress() { Suppressions::Suppression s; std::string msg;