Fixed #2053 (false positive on list erase)

This commit is contained in:
Daniel Marjamäki 2010-09-18 16:46:38 +02:00
parent c1bf388b15
commit 395f10aa6d
2 changed files with 25 additions and 0 deletions

View File

@ -131,6 +131,10 @@ void CheckStl::iterators()
{
validIterator = true;
}
else if (tok2->str() == "else")
{
validIterator = true;
}
}
}
}

View File

@ -56,6 +56,7 @@ private:
TEST_CASE(eraseContinue);
TEST_CASE(eraseReturn1);
TEST_CASE(eraseReturn2);
TEST_CASE(eraseReturn3);
TEST_CASE(eraseGoto);
TEST_CASE(eraseAssign1);
TEST_CASE(eraseAssign2);
@ -513,6 +514,26 @@ private:
ASSERT_EQUALS("", errout.str());
}
void eraseReturn3()
{
check("void f()\n"
"{\n"
" std::vector<int> foo;\n"
" std::vector<int>::iterator it;\n"
" for (it = foo.begin(); it != foo.end(); ++it)\n"
" {\n"
" if (somecondition) {\n"
" if (*it == 1)\n"
" foo.erase(it);\n"
" else\n"
" *it = 0;\n"
" return;\n"
" }\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void eraseGoto()
{
check("void f()\n"