diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 5ee3535e4..859b62e47 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -306,8 +306,6 @@ private: break; else if (token->str() == "=") token = 0; - else - token = token->previous(); } if (token) diff --git a/test/teststl.cpp b/test/teststl.cpp index 4d9c02238..0503b567f 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -384,6 +384,16 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + // #2101 + check("void f(vector< list > &ints, unsigned int i)\n" + "{\n" + " list::iterator it;\n" + " for(it = ints[i].begin(); it != ints[i].end(); it++) {\n" + " if (*it % 2)\n" + " it = ints[i].erase(it);\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void erase2()