CheckCondition: Fix FP when there is increment/decrement in condition (daca icu)
This commit is contained in:
parent
c34fdd1905
commit
db321c2617
|
@ -550,6 +550,24 @@ void CheckCondition::multiCondition2()
|
||||||
|
|
||||||
for (; tok && tok != endToken; tok = tok->next()) {
|
for (; tok && tok != endToken; tok = tok->next()) {
|
||||||
if (Token::simpleMatch(tok, "if (")) {
|
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..
|
// Condition..
|
||||||
const Token *cond2 = tok->next()->astOperand2();
|
const Token *cond2 = tok->next()->astOperand2();
|
||||||
|
|
||||||
|
|
|
@ -1852,6 +1852,13 @@ private:
|
||||||
" if (failed) {}\n"
|
" if (failed) {}\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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
|
// clarify conditions with = and comparison
|
||||||
|
|
Loading…
Reference in New Issue