diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 0b3121eb1..efa695067 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -550,6 +550,24 @@ void CheckCondition::multiCondition2() for (; tok && tok != endToken; tok = tok->next()) { if (Token::simpleMatch(tok, "if (")) { + // Does condition modify tracked variables? + if (const Token *op = Token::findmatch(tok, "++|--", tok->linkAt(1))) { + bool bailout = false; + while (op) { + if (vars.find(op->astOperand1()->varId()) != vars.end()) { + bailout = true; + break; + } + if (nonlocal && op->astOperand1()->varId() == 0) { + bailout = true; + break; + } + op = Token::findmatch(op->next(), "++|--", tok->linkAt(1)); + } + if (bailout) + break; + } + // Condition.. const Token *cond2 = tok->next()->astOperand2(); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 430867d11..5d33eb2e9 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1852,6 +1852,13 @@ private: " if (failed) {}\n" "}"); ASSERT_EQUALS("", errout.str()); + + // daca icu + check("void f(const uint32_t *section, int32_t start) {\n" + " if(10<=section[start]) { return; }\n" + " if(++start<100 && 10<=section[start]) { }\n" + "}"); + ASSERT_EQUALS("", errout.str()); } // clarify conditions with = and comparison