Fixed #2450 (False positive when iterator reused)

This commit is contained in:
Daniel Marjamäki 2011-01-13 20:57:44 +01:00
parent 36c1807228
commit b247d7d56e
2 changed files with 11 additions and 1 deletions

View File

@ -968,7 +968,7 @@ void CheckStl::missingComparison()
incrementToken = tok3;
else if (tok3->varId() == iteratorId && Token::Match(tok3->next(), "!=|=="))
incrementToken = 0;
else if (tok3->str() == "break")
else if (tok3->str() == "break" || tok3->str() == "return")
incrementToken = 0;
}
if (incrementToken)

View File

@ -1118,6 +1118,16 @@ private:
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
check("function f1(std::list<int> &l1) {\n"
" for(std::list<int>::iterator i = l1.begin(); i != l1.end(); i++) {\n"
" if (*i == 44) {\n"
" l1.insert(++i, 55);\n"
" return;\n"
" }\n"
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void missingInnerComparison5()