AST: Improved astIsFloat handling of expressions
This commit is contained in:
parent
abdf2bb9d4
commit
da540a3bb3
|
@ -3359,6 +3359,11 @@ void CheckOther::complexDuplicateExpressionCheck(const std::list<const Function*
|
|||
|
||||
static bool astIsFloat(const Token *tok)
|
||||
{
|
||||
if (tok->astOperand1() && astIsFloat(tok->astOperand1()))
|
||||
return true;
|
||||
if (tok->astOperand2() && astIsFloat(tok->astOperand2()))
|
||||
return true;
|
||||
|
||||
// TODO: check function calls, struct members, arrays, etc also
|
||||
return tok->variable() && Token::Match(tok->variable()->typeStartToken(), "float|double");
|
||||
}
|
||||
|
|
|
@ -4872,6 +4872,13 @@ private:
|
|||
|
||||
check("float f(float x) { return x-x; }"); // ticket #4485 (Inf)
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("float f(float x) { return (X double)x == (X double)x; }", NULL, false, false, false, false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct X { float f; };\n"
|
||||
"float f(struct X x) { return x.f == x.f; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void duplicateExpression3() {
|
||||
|
|
Loading…
Reference in New Issue