You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 644096a
Browse filesBrowse the repository at this point in the historyBrowse files
if (stepTok->isIncDecOp() && stepTok->astOperand1() && stepTok->astOperand1()->varId() == varId)
4920
4918
returntrue;
4921
-
if (stepTok->isAssignmentOp() && stepTok->astOperand1() && stepTok->astOperand1()->varId() == varId)// TODO: WILL THIS RETURN TRUE IF STEP IS SOMETHING LIKE: i=i
4919
+
if (stepTok->isAssignmentOp() && stepTok->astOperand1() && stepTok->astOperand1()->varId() == varId)
4922
4920
returntrue;
4923
-
returnfalse;
4921
+
// Recurse so nested updates are found, e.g. "delete *it++" or "a = b++"
Copy file name to clipboardExpand all lines: test/testother.cpp
+19-2Lines changed: 19 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6682,7 +6682,8 @@ class TestOther : public TestFixture {
6682
6682
" c ++;\n"
6683
6683
" }\n"
6684
6684
"}\n");
6685
-
ASSERT_EQUALS("[test.cpp:2:31]: (warning, inconclusive) Found suspicious equality comparison. Did you intend to assign a value instead? [constStatement]\n", errout_str());
6685
+
ASSERT_EQUALS("[test.cpp:2:31]: (warning, inconclusive) Found suspicious equality comparison. Did you intend to assign a value instead? [constStatement]\n"
6686
+
"[test.cpp:2:5]: (warning) The loop variable 'i' is not updated in this for-loop, so the loop might never terminate. [missingForLoopIncrement]\n", errout_str());
6686
6687
6687
6688
check("void foo(int c) {\n"
6688
6689
" for (; running == 1;) {\n"
@@ -8641,7 +8642,8 @@ class TestOther : public TestFixture {
8641
8642
" if( i != 0 ) {}\n"
8642
8643
" }\n"
8643
8644
"}\n");
8644
-
ASSERT_EQUALS("[test.cpp:2:17] -> [test.cpp:3:15]: (style) The comparison 'i != 0' is always false. [knownConditionTrueFalse]\n", errout_str());
8645
+
ASSERT_EQUALS("[test.cpp:2:17] -> [test.cpp:3:15]: (style) The comparison 'i != 0' is always false. [knownConditionTrueFalse]\n"
8646
+
"[test.cpp:2:5]: (warning) The loop variable 'i' is not updated in this for-loop, so the loop might never terminate. [missingForLoopIncrement]\n", errout_str());
8645
8647
8646
8648
check("void f() {\n"
8647
8649
" for(int i = 0; i < 10;) {\n"
@@ -14694,6 +14696,21 @@ class TestOther : public TestFixture {
14694
14696
" }\n"
14695
14697
"}\n");
14696
14698
ASSERT_EQUALS("", errout_str());
14699
+
14700
+
// Nested update in step — OK
14701
+
check("void f(const std::vector<int*>& v) {\n"
14702
+
" for (auto it = v.begin(); it != v.end(); delete *it++);\n"
14703
+
"}\n");
14704
+
ASSERT_EQUALS("", errout_str());
14705
+
14706
+
// Loop var updated on RHS of step assignment — OK
0 commit comments