File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1732,8 +1732,6 @@ void CheckStl::missingComparison()
17321732 }
17331733
17341734 const Token *incrementToken = nullptr ;
1735- bool bComparedInAdvance = false ;
1736-
17371735 // Parse loop..
17381736 for (const Token *tok3 = scope.bodyStart ; tok3 != scope.bodyEnd ; tok3 = tok3->next ()) {
17391737 if (tok3->varId () == iteratorId) {
@@ -1742,16 +1740,13 @@ void CheckStl::missingComparison()
17421740 tok3 = tok3->linkAt (6 );
17431741 if (!tok3)
17441742 break ;
1745- } else if (Token::simpleMatch (tok3->astParent (), " ++" )) {
1746- if (!bComparedInAdvance)
1743+ } else if (Token::simpleMatch (tok3->astParent (), " ++" ))
17471744 incrementToken = tok3;
1748- else
1749- bComparedInAdvance = false ;
1750- } else if (Token::simpleMatch (tok3->astParent (), " +" )) {
1751- if (Token::simpleMatch (tok3->astSibling (), " 1" )) {
1745+ else if (Token::simpleMatch (tok3->astParent (), " +" )) {
1746+ if (Token::Match (tok3->astSibling (), " %num%" )) {
17521747 const Token* tokenGrandParent = tok3->astParent ()->astParent ();
17531748 if (Token::Match (tokenGrandParent, " ==|!=" ))
1754- bComparedInAdvance = true ;
1749+ break ;
17551750 }
17561751 } else if (Token::Match (tok3->astParent (), " ==|!=" ))
17571752 incrementToken = nullptr ;
Original file line number Diff line number Diff line change @@ -3004,8 +3004,11 @@ class TestStl : public TestFixture {
30043004
30053005 check (" void f(const std::vector<std::string> &v) {\n "
30063006 " for(std::vector<std::string>::const_iterator it = v.begin(); it != v.end(); ++it) {\n "
3007- " if(it+1 != v.end())\n "
3007+ " if(it+2 != v.end())\n "
3008+ " {\n "
3009+ " ++it;\n "
30083010 " ++it;\n "
3011+ " }\n "
30093012 " }\n "
30103013 " }" );
30113014 ASSERT_EQUALS (" " , errout.str ());
You can’t perform that action at this time.
0 commit comments