diff --git a/cppcheck.cbp b/cppcheck.cbp index f15ed8b6a..edd27b2be 100644 --- a/cppcheck.cbp +++ b/cppcheck.cbp @@ -29,6 +29,8 @@ + + @@ -45,13 +47,25 @@ + + + + + + + + + + + + @@ -60,6 +74,8 @@ + + @@ -86,8 +102,12 @@ + + + + @@ -107,18 +127,27 @@ + + + + + + + + + @@ -128,11 +157,15 @@ + + + + @@ -143,6 +176,12 @@ + + + + + + diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index b9beae19a..9825c7967 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -899,6 +899,8 @@ void CheckStl::missingComparison() incrementToken = tok3; else if (tok3->varId() == iteratorId && Token::Match(tok3->next(), "!=|==")) incrementToken = 0; + else if (tok3->str() == "break") + incrementToken = 0; } if (incrementToken) missingComparisonError(incrementToken, tok2->tokAt(16)); diff --git a/test/teststl.cpp b/test/teststl.cpp index 4e6982106..87d21aa86 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -98,6 +98,7 @@ private: TEST_CASE(missingInnerComparison1); TEST_CASE(missingInnerComparison2); // no FP when there is comparison TEST_CASE(missingInnerComparison3); // no FP when there is iterator shadowing + TEST_CASE(missingInnerComparison4); // no FP when "break;" is used // catch common problems when using the string::c_str() function TEST_CASE(cstr); @@ -1094,6 +1095,19 @@ private: ASSERT_EQUALS("", errout.str()); } + void missingInnerComparison4() + { + check("function f1(std::list &l1) {\n" + " for(std::list::iterator i = l1.begin(); i != l1.end(); i++) {\n" + " if (*i == 44) {\n" + " l1.insert(++i, 55);\n" + " break;\n" + " }\n" + " }\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } + void cstr() { check("void f() {\n"