Fix issue 10379: FP knownConditionTrueFalse with mod operator (#3354)
This commit is contained in:
parent
f9516cf1c6
commit
8e416a7255
|
@ -1533,7 +1533,7 @@ static std::vector<MathLib::bigint> minUnsignedValue(const Token* tok, int depth
|
||||||
return result;
|
return result;
|
||||||
if (tok->hasKnownIntValue()) {
|
if (tok->hasKnownIntValue()) {
|
||||||
result = {tok->values().front().intvalue};
|
result = {tok->values().front().intvalue};
|
||||||
} else if (tok->str() != "-" && tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
|
} else if (!Token::Match(tok, "-|%") && tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
|
||||||
std::vector<MathLib::bigint> op1 = minUnsignedValue(tok->astOperand1(), depth - 1);
|
std::vector<MathLib::bigint> op1 = minUnsignedValue(tok->astOperand1(), depth - 1);
|
||||||
std::vector<MathLib::bigint> op2 = minUnsignedValue(tok->astOperand2(), depth - 1);
|
std::vector<MathLib::bigint> op2 = minUnsignedValue(tok->astOperand2(), depth - 1);
|
||||||
if (!op1.empty() && !op2.empty()) {
|
if (!op1.empty() && !op2.empty()) {
|
||||||
|
|
|
@ -5859,6 +5859,13 @@ private:
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 4U, 0));
|
ASSERT_EQUALS(false, testValueOfXImpossible(code, 4U, 0));
|
||||||
ASSERT_EQUALS(true, testValueOfXImpossible(code, 4U, -1));
|
ASSERT_EQUALS(true, testValueOfXImpossible(code, 4U, -1));
|
||||||
|
|
||||||
|
code = "auto f(uint32_t i) {\n"
|
||||||
|
" auto x = (i + 1) % 16;\n"
|
||||||
|
" return x;\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(false, testValueOfXImpossible(code, 3U, 0));
|
||||||
|
ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowMod() {
|
void valueFlowMod() {
|
||||||
|
|
Loading…
Reference in New Issue