Fix 10390: FP: knownConditionTrueFalse (#3374)
This commit is contained in:
parent
405e17985a
commit
61ceff39f5
|
@ -4031,6 +4031,10 @@ static void valueFlowSymbolic(TokenList* tokenlist, SymbolDatabase* symboldataba
|
||||||
continue;
|
continue;
|
||||||
if (tok->astOperand2()->hasKnownIntValue())
|
if (tok->astOperand2()->hasKnownIntValue())
|
||||||
continue;
|
continue;
|
||||||
|
if (tok->astOperand1()->exprId() == 0)
|
||||||
|
continue;
|
||||||
|
if (tok->astOperand2()->exprId() == 0)
|
||||||
|
continue;
|
||||||
if (!isConstExpression(tok->astOperand2(), tokenlist->getSettings()->library, true, tokenlist->isCPP()))
|
if (!isConstExpression(tok->astOperand2(), tokenlist->getSettings()->library, true, tokenlist->isCPP()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -4068,6 +4072,10 @@ static void valueFlowSymbolicInfer(TokenList* tokenlist, SymbolDatabase* symbold
|
||||||
continue;
|
continue;
|
||||||
if (tok->astOperand2()->hasKnownIntValue())
|
if (tok->astOperand2()->hasKnownIntValue())
|
||||||
continue;
|
continue;
|
||||||
|
if (astIsFloat(tok->astOperand1(), false))
|
||||||
|
continue;
|
||||||
|
if (astIsFloat(tok->astOperand2(), false))
|
||||||
|
continue;
|
||||||
|
|
||||||
MathLib::bigint rhsvalue = 0;
|
MathLib::bigint rhsvalue = 0;
|
||||||
const ValueFlow::Value* rhs =
|
const ValueFlow::Value* rhs =
|
||||||
|
|
|
@ -6007,6 +6007,20 @@ private:
|
||||||
" return x;\n"
|
" return x;\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, "i++", 0));
|
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, "i++", 0));
|
||||||
|
|
||||||
|
code = "float foo() {\n"
|
||||||
|
" float f = 1.0f;\n"
|
||||||
|
" float x = f;\n"
|
||||||
|
" return x;\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, "1.0f", 0));
|
||||||
|
|
||||||
|
code = "int foo(float f) {\n"
|
||||||
|
" float g = f;\n"
|
||||||
|
" int x = f == g;\n"
|
||||||
|
" return x;\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, 1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue