value flow: fixed fp for nested assignments
This commit is contained in:
parent
4d045879aa
commit
680d3f1312
|
@ -90,12 +90,17 @@ static bool bailoutSelfAssignment(const Token * const tok)
|
|||
parent = parent->astParent();
|
||||
|
||||
// Assignment where lhs variable exists in rhs => return true
|
||||
if (parent != NULL &&
|
||||
parent->astOperand2() == op &&
|
||||
parent->astOperand1() != NULL &&
|
||||
parent->str() == "=" &&
|
||||
parent->astOperand1()->str() == tok->str())
|
||||
return true;
|
||||
if (parent != NULL &&
|
||||
parent->astOperand2() == op &&
|
||||
parent->astOperand1() != NULL &&
|
||||
parent->str() == "=") {
|
||||
for (const Token *lhs = parent->astOperand1(); lhs; lhs = lhs->astOperand1()) {
|
||||
if (lhs->varId() == tok->varId())
|
||||
return true;
|
||||
if (lhs->astOperand2() && lhs->astOperand2()->varId() == tok->varId())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -111,6 +111,11 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 2U, 65));
|
||||
|
||||
code = "void f(int x) {\n"
|
||||
" x = y = 2 + x;\n"
|
||||
" if (x == 65);\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 2U, 65));
|
||||
|
||||
// guarding by &&
|
||||
code = "void f(int x) {\n"
|
||||
|
|
Loading…
Reference in New Issue