From a42dd2ffe0565d827d1e06f79c4d0973fa5a71c7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 16 Jun 2020 10:51:41 +0200 Subject: Cleanup float-equal warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consistently use the macro from qcompilerdetection.h instead of manually disabling the warning for three different compilers. Change-Id: Id59d30047c8a504e1082d7e47c02f4746fddf9d6 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/global/qfloat16.h | 4 +--- src/corelib/global/qglobal.h | 4 +--- src/corelib/global/qnumeric_p.h | 3 +-- src/corelib/tools/qpoint.h | 4 +--- src/corelib/tools/qrect.h | 4 +--- src/gui/math3d/qmatrix4x4.h | 5 ++--- src/gui/math3d/qquaternion.h | 5 ++--- src/gui/math3d/qvector2d.h | 5 ++--- src/gui/math3d/qvector3d.h | 5 ++--- src/gui/math3d/qvector4d.h | 5 ++--- src/gui/painting/qtransform.h | 4 +--- 11 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index f35eefd922..a25130958f 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -242,9 +242,7 @@ QF16_MAKE_ARITH_OP_INT(/) #undef QF16_MAKE_ARITH_OP_INT QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) > static_cast(b); } inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast(a) < static_cast(b); } diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 6bfb73eb5c..7b2b6846f2 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -866,9 +866,7 @@ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNul } QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qIsNull(double d) noexcept { diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 7a03e32699..27490bce97 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -240,8 +240,7 @@ template static inline bool convertDoubleTo(double v, T *value, boo *value = T(v); QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_FLOAT_COMPARE return *value == v; diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index 075893978d..725787265f 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -349,9 +349,7 @@ constexpr inline QPointF &QPointF::operator*=(qreal c) } QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE constexpr inline bool operator==(const QPointF &p1, const QPointF &p2) { diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index c6bfc1a50d..1530ed2623 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -663,9 +663,7 @@ Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) noexcept } QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE Q_DECL_CONSTEXPR inline bool QRectF::isNull() const noexcept { return w == 0. && h == 0.; } diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 64bf9c607e..4f1a74a834 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -214,9 +214,8 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QMatrix4x4::Flags) QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE + Q_DECLARE_TYPEINFO(QMatrix4x4, Q_MOVABLE_TYPE); inline QMatrix4x4::QMatrix4x4 diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index f01fab679e..f862e6174c 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -169,9 +169,8 @@ inline QQuaternion::QQuaternion() : wp(1.0f), xp(0.0f), yp(0.0f), zp(0.0f) {} inline QQuaternion::QQuaternion(float aScalar, float xpos, float ypos, float zpos) : wp(aScalar), xp(xpos), yp(ypos), zp(zpos) {} QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE + inline bool QQuaternion::isNull() const { return wp == 0.0f && xp == 0.0f && yp == 0.0f && zp == 0.0f; diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index cbce94c199..65ad2a3afd 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -205,9 +205,8 @@ inline QVector2D &QVector2D::operator/=(const QVector2D &vector) } QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE + Q_DECL_CONSTEXPR inline bool operator==(const QVector2D &v1, const QVector2D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1]; diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index d7ffb0bcc4..9eb2e7e7e6 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -230,9 +230,8 @@ inline QVector3D &QVector3D::operator/=(const QVector3D &vector) } QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE + Q_DECL_CONSTEXPR inline bool operator==(const QVector3D &v1, const QVector3D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2]; diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index afcc71fa88..495a0b7e23 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -230,9 +230,8 @@ inline QVector4D &QVector4D::operator/=(const QVector4D &vector) } QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE + Q_DECL_CONSTEXPR inline bool operator==(const QVector4D &v1, const QVector4D &v2) { return v1.v[0] == v2.v[0] && v1.v[1] == v2.v[1] && v1.v[2] == v2.v[2] && v1.v[3] == v2.v[3]; diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index def75d0ceb..972e45146a 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -269,9 +269,7 @@ inline qreal QTransform::dy() const } QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -QT_WARNING_DISABLE_GCC("-Wfloat-equal") -QT_WARNING_DISABLE_INTEL(1572) +QT_WARNING_DISABLE_FLOAT_COMPARE inline QTransform &QTransform::operator*=(qreal num) { -- cgit v1.2.3