inline suppressions: treat arithmetic operators as start-of-comment

This commit is contained in:
Daniel Marjamäki 2018-06-09 22:50:51 +02:00
parent 8290d84472
commit 03b2e0eee7
2 changed files with 14 additions and 0 deletions

View File

@ -205,6 +205,8 @@ bool Suppressions::Suppression::parseComment(std::string comment, std::string *e
iss >> word;
if (!iss)
break;
if (word.find_first_not_of("+-*/%#;") == std::string::npos)
break;
if (word.compare(0,11,"symbolName=")==0)
symbolName = word.substr(11);
else if (errorMessage && errorMessage->empty())

View File

@ -49,6 +49,7 @@ private:
TEST_CASE(inlinesuppress);
TEST_CASE(inlinesuppress_symbolname);
TEST_CASE(inlinesuppress_comment);
TEST_CASE(globalSuppressions); // Testing that global suppressions work (#8515)
@ -434,6 +435,17 @@ private:
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str());
}
void inlinesuppress_comment() {
Suppressions::Suppression s;
std::string errmsg;
ASSERT_EQUALS(true, s.parseComment("// cppcheck-suppress abc ; some comment", &errmsg));
ASSERT_EQUALS("", errmsg);
ASSERT_EQUALS(true, s.parseComment("// cppcheck-suppress abc // some comment", &errmsg));
ASSERT_EQUALS("", errmsg);
ASSERT_EQUALS(true, s.parseComment("// cppcheck-suppress abc -- some comment", &errmsg));
ASSERT_EQUALS("", errmsg);
}
void globalSuppressions() { // Testing that Cppcheck::useGlobalSuppressions works (#8515)
errout.str("");