inline suppressions: treat arithmetic operators as start-of-comment
This commit is contained in:
parent
8290d84472
commit
03b2e0eee7
|
@ -205,6 +205,8 @@ bool Suppressions::Suppression::parseComment(std::string comment, std::string *e
|
||||||
iss >> word;
|
iss >> word;
|
||||||
if (!iss)
|
if (!iss)
|
||||||
break;
|
break;
|
||||||
|
if (word.find_first_not_of("+-*/%#;") == std::string::npos)
|
||||||
|
break;
|
||||||
if (word.compare(0,11,"symbolName=")==0)
|
if (word.compare(0,11,"symbolName=")==0)
|
||||||
symbolName = word.substr(11);
|
symbolName = word.substr(11);
|
||||||
else if (errorMessage && errorMessage->empty())
|
else if (errorMessage && errorMessage->empty())
|
||||||
|
|
|
@ -49,6 +49,7 @@ private:
|
||||||
|
|
||||||
TEST_CASE(inlinesuppress);
|
TEST_CASE(inlinesuppress);
|
||||||
TEST_CASE(inlinesuppress_symbolname);
|
TEST_CASE(inlinesuppress_symbolname);
|
||||||
|
TEST_CASE(inlinesuppress_comment);
|
||||||
|
|
||||||
TEST_CASE(globalSuppressions); // Testing that global suppressions work (#8515)
|
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());
|
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)
|
void globalSuppressions() { // Testing that Cppcheck::useGlobalSuppressions works (#8515)
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue