This commit is contained in:
parent
0c3531ea61
commit
8df25ec4e9
|
@ -660,22 +660,8 @@ void CheckCondition::multiCondition2()
|
|||
const Token * condStartToken = tok->str() == "if" ? tok->next() : tok;
|
||||
const Token * condEndToken = tok->str() == "if" ? condStartToken->link() : Token::findsimplematch(condStartToken, ";");
|
||||
// Does condition modify tracked variables?
|
||||
if (const Token *op = Token::findmatch(tok, "++|--", condEndToken)) {
|
||||
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(), "++|--", condEndToken);
|
||||
}
|
||||
if (bailout)
|
||||
break;
|
||||
}
|
||||
if (isExpressionChanged(cond1, condStartToken, condEndToken, mSettings, mTokenizer->isCPP()))
|
||||
break;
|
||||
|
||||
// Condition..
|
||||
const Token *cond2 = tok->str() == "if" ? condStartToken->astOperand2() : condStartToken->astOperand1();
|
||||
|
|
|
@ -3810,6 +3810,24 @@ private:
|
|||
" uint8_t d0 = message->length > 0 ? data[0] : 0xff;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #8266
|
||||
check("void f(bool b) {\n"
|
||||
" if (b)\n"
|
||||
" return;\n"
|
||||
" if (g(&b) || b)\n"
|
||||
" return;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #9720
|
||||
check("bool bar(int &);\n"
|
||||
"void f(int a, int b) {\n"
|
||||
" if (a + b == 3)\n"
|
||||
" return;\n"
|
||||
" if (bar(a) && (a + b == 3)) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueSymbolic()
|
||||
|
|
Loading…
Reference in New Issue