CheckCondition: Fix FP when there is increment/decrement in condition (daca icu)

This commit is contained in:
Daniel Marjamäki 2017-09-10 22:58:05 +02:00
parent c34fdd1905
commit db321c2617
2 changed files with 25 additions and 0 deletions

View File

@ -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();

View File

@ -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