Fixed #2154 (false positive: The loop might unintentionally skip an element in the container)
This commit is contained in:
parent
54cb7bf070
commit
7b630cc581
|
@ -880,6 +880,9 @@ void CheckStl::missingComparison()
|
|||
}
|
||||
|
||||
const unsigned int &iteratorId(tok2->varId());
|
||||
if (iteratorId == 0)
|
||||
continue;
|
||||
|
||||
const Token *incrementToken = 0;
|
||||
unsigned int indentlevel = 0;
|
||||
// Parse loop..
|
||||
|
|
|
@ -99,6 +99,7 @@ private:
|
|||
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
|
||||
TEST_CASE(missingInnerComparison5); // Ticket #2154 - FP
|
||||
|
||||
// catch common problems when using the string::c_str() function
|
||||
TEST_CASE(cstr);
|
||||
|
@ -1108,6 +1109,16 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void missingInnerComparison5()
|
||||
{
|
||||
check("void f() {\n"
|
||||
" for(it = map1.begin(); it != map1.end(); it++) {\n"
|
||||
" str[i++] = (*it).first;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void cstr()
|
||||
{
|
||||
check("void f() {\n"
|
||||
|
|
Loading…
Reference in New Issue