diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index d22f4415c..899455bd7 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -224,7 +224,7 @@ std::string Suppressions::addSuppression(const std::string &errorId, const std:: } if (errorId != "*") { for (std::string::size_type pos = 0; pos < errorId.length(); ++pos) { - if (errorId[pos] < 0 || !std::isalnum(errorId[pos])) { + if (errorId[pos] < 0 || (!std::isalnum(errorId[pos]) && errorId[pos] != '_')) { return "Failed to add suppression. Invalid id \"" + errorId + "\""; } if (pos == 0 && std::isdigit(errorId[pos])) { diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index f86433866..91e27c5f0 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -45,8 +45,11 @@ private: void suppressionsBadId1() { Suppressions suppressions; - std::istringstream s("123"); - ASSERT_EQUALS("Failed to add suppression. Invalid id \"123\"", suppressions.parseFile(s)); + std::istringstream s1("123"); + ASSERT_EQUALS("Failed to add suppression. Invalid id \"123\"", suppressions.parseFile(s1)); + + std::istringstream s2("obsoleteFunctionsrand_r"); + ASSERT_EQUALS("", suppressions.parseFile(s2)); } void suppressionsDosFormat() {