From 6edec7bdcec0113da2f63c6d44563136628621cc Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 6 Sep 2012 16:10:51 +0200 Subject: [PATCH] Fixed false positive #4123. --- lib/checkstl.cpp | 2 +- test/teststl.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index f6931ca20..67717a4f3 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -145,7 +145,7 @@ void CheckStl::iterators() } // Reassign the iterator - else if (Token::Match(tok2, "%varid% = %var%", iteratorId)) { + else if (Token::Match(tok2, "%varid% = %any%", iteratorId)) { // Assume that the iterator becomes valid. // TODO: add checking that checks if the iterator becomes valid or not validatingToken = Token::findmatch(tok2->tokAt(2), "[;)]"); diff --git a/test/teststl.cpp b/test/teststl.cpp index 881838cd4..48ceeb654 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -66,6 +66,7 @@ private: TEST_CASE(eraseGoto); TEST_CASE(eraseAssign1); TEST_CASE(eraseAssign2); + TEST_CASE(eraseAssign3); TEST_CASE(eraseErase); TEST_CASE(eraseByValue); @@ -858,6 +859,15 @@ private: ASSERT_EQUALS("", errout.str()); } + void eraseAssign3() { + check("void f(std::list >& l) {\n" + " std::list >::const_iterator i = l.begin();\n" + " std::list::const_iterator j = (*i).begin();\n" + " cout << *j << endl;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } + void eraseErase() { check("void f(std::vector &ints)\n" "{\n"