File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,7 +168,9 @@ void CheckStl::iterators()
168168 // inserting iterator range..
169169 if (tok2->strAt (2 ) == " insert" ) {
170170 const Token *par2 = itTok->nextArgument ();
171- while (par2 && par2->str () != " )" ) {
171+ if (!par2 || par2->nextArgument ())
172+ continue ;
173+ while (par2->str () != " )" ) {
172174 if (par2->varId () == container->declarationId ())
173175 break ;
174176 if (par2->str () == " (" )
Original file line number Diff line number Diff line change @@ -209,6 +209,23 @@ class TestStl : public TestFixture {
209209 " l2.insert(it, l1.end());\n "
210210 " }" );
211211 ASSERT_EQUALS (" " , errout.str ());
212+
213+ // only warn for insert when there are preciself 2 arguments.
214+ check (" void foo() {\n "
215+ " list<int> l1;\n "
216+ " list<int> l2;\n "
217+ " list<int>::iterator it = l1.begin();\n "
218+ " l2.insert(it);\n "
219+ " }" );
220+ ASSERT_EQUALS (" " , errout.str ());
221+ check (" void foo() {\n "
222+ " list<int> l1;\n "
223+ " list<int> l2;\n "
224+ " list<int>::iterator it = l1.begin();\n "
225+ " l2.insert(it,0,1);\n "
226+ " }" );
227+ ASSERT_EQUALS (" " , errout.str ());
228+
212229 }
213230
214231 void iterator4 () {
You can’t perform that action at this time.
0 commit comments