Fixed false positive #4077.
This commit is contained in:
parent
1c7027140a
commit
a8cdd15738
|
@ -154,6 +154,11 @@ void CheckStl::iterators()
|
||||||
tok2 = tok2->tokAt(2);
|
tok2 = tok2->tokAt(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Passing iterator to function. Iterator might be initialized
|
||||||
|
else if (Token::Match(tok2, "%varid% ,|)", iteratorId)) {
|
||||||
|
validIterator = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Dereferencing invalid iterator?
|
// Dereferencing invalid iterator?
|
||||||
else if (!validIterator && Token::Match(tok2, "* %varid%", iteratorId)) {
|
else if (!validIterator && Token::Match(tok2, "* %varid%", iteratorId)) {
|
||||||
dereferenceErasedError(tok2, tok2->strAt(1));
|
dereferenceErasedError(tok2, tok2->strAt(1));
|
||||||
|
|
|
@ -67,6 +67,7 @@ private:
|
||||||
TEST_CASE(eraseAssign1);
|
TEST_CASE(eraseAssign1);
|
||||||
TEST_CASE(eraseAssign2);
|
TEST_CASE(eraseAssign2);
|
||||||
TEST_CASE(eraseAssign3);
|
TEST_CASE(eraseAssign3);
|
||||||
|
TEST_CASE(eraseAssignByFunctionCall);
|
||||||
TEST_CASE(eraseErase);
|
TEST_CASE(eraseErase);
|
||||||
TEST_CASE(eraseByValue);
|
TEST_CASE(eraseByValue);
|
||||||
|
|
||||||
|
@ -868,6 +869,15 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void eraseAssignByFunctionCall() {
|
||||||
|
check("void f(std::list<list<int> >& l) {\n"
|
||||||
|
" std::list<foo>::const_iterator i;\n"
|
||||||
|
" bar(i);\n"
|
||||||
|
" cout << *i;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void eraseErase() {
|
void eraseErase() {
|
||||||
check("void f(std::vector<ints> &ints)\n"
|
check("void f(std::vector<ints> &ints)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue