Fix GCC -Wfloat-conversion warnings (available since GCC 4.9)
This warning used to be part of -Wconversion, but that generates too more noise than we're willing to fix now (like conversion from qint64 to int). The float conversion does trigger for conversion from double to float, as shown in all the QVectorND uses of float, but more importantly, it triggers on passing floats to ints. Change-Id: I69f37f9304f24709a823fffd14e69cfd33f75988 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
0e0f656f50
commit
fb59760381
@ -222,6 +222,7 @@ headersclean:!internal_module {
|
||||
|
||||
gcc_ver = $${QT_GCC_MAJOR_VERSION}.$${QT_GCC_MINOR_VERSION}
|
||||
versionAtLeast(gcc_ver, 4.5): hcleanFLAGS += -Wdouble-promotion
|
||||
versionAtLeast(gcc_ver, 4.9): hcleanFLAGS += -Wfloat-conversion
|
||||
|
||||
c++11 {
|
||||
# only enabled for actual c++11 builds due to
|
||||
|
@ -167,7 +167,8 @@ inline qfloat16 operator/(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return qfloat
|
||||
inline FP operator OP(qfloat16 lhs, FP rhs) Q_DECL_NOTHROW { return static_cast<FP>(lhs) OP rhs; } \
|
||||
inline FP operator OP(FP lhs, qfloat16 rhs) Q_DECL_NOTHROW { return lhs OP static_cast<FP>(rhs); }
|
||||
#define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \
|
||||
inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) Q_DECL_NOTHROW { lhs = qfloat16(static_cast<FP>(lhs) OP rhs); return lhs; }
|
||||
inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) Q_DECL_NOTHROW \
|
||||
{ lhs = qfloat16(float(static_cast<FP>(lhs) OP rhs)); return lhs; }
|
||||
#define QF16_MAKE_ARITH_OP(FP) \
|
||||
QF16_MAKE_ARITH_OP_FP(FP, +) \
|
||||
QF16_MAKE_ARITH_OP_FP(FP, -) \
|
||||
|
@ -205,10 +205,10 @@ public:
|
||||
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
|
||||
inline QPoint pos() const { return p.toPoint(); }
|
||||
inline QPoint globalPos() const { return g.toPoint(); }
|
||||
inline int x() const { return p.x(); }
|
||||
inline int y() const { return p.y(); }
|
||||
inline int globalX() const { return g.x(); }
|
||||
inline int globalY() const { return g.y(); }
|
||||
inline int x() const { return int(p.x()); }
|
||||
inline int y() const { return int(p.y()); }
|
||||
inline int globalX() const { return int(g.x()); }
|
||||
inline int globalY() const { return int(g.y()); }
|
||||
#endif
|
||||
inline const QPointF &posF() const { return p; }
|
||||
inline const QPointF &globalPosF() const { return g; }
|
||||
|
@ -859,8 +859,8 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
|
||||
{
|
||||
float xin, yin;
|
||||
float x, y, w;
|
||||
xin = point.x();
|
||||
yin = point.y();
|
||||
xin = float(point.x());
|
||||
yin = float(point.y());
|
||||
x = xin * matrix.m[0][0] +
|
||||
yin * matrix.m[0][1] +
|
||||
matrix.m[0][3];
|
||||
@ -1094,7 +1094,7 @@ inline float *QMatrix4x4::data()
|
||||
|
||||
inline void QMatrix4x4::viewport(const QRectF &rect)
|
||||
{
|
||||
viewport(rect.x(), rect.y(), rect.width(), rect.height());
|
||||
viewport(float(rect.x()), float(rect.y()), float(rect.width()), float(rect.height()));
|
||||
}
|
||||
|
||||
QT_WARNING_POP
|
||||
|
@ -210,8 +210,8 @@ inline QQuaternion QQuaternion::inverted() const
|
||||
double(yp) * double(yp) +
|
||||
double(zp) * double(zp);
|
||||
if (!qFuzzyIsNull(len))
|
||||
return QQuaternion(double(wp) / len, double(-xp) / len,
|
||||
double(-yp) / len, double(-zp) / len);
|
||||
return QQuaternion(float(double(wp) / len), float(double(-xp) / len),
|
||||
float(double(-yp) / len), float(double(-zp) / len));
|
||||
return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ Q_DECL_CONSTEXPR inline QVector2D::QVector2D(float xpos, float ypos) : xp(xpos),
|
||||
|
||||
Q_DECL_CONSTEXPR inline QVector2D::QVector2D(const QPoint& point) : xp(point.x()), yp(point.y()) {}
|
||||
|
||||
Q_DECL_CONSTEXPR inline QVector2D::QVector2D(const QPointF& point) : xp(point.x()), yp(point.y()) {}
|
||||
Q_DECL_CONSTEXPR inline QVector2D::QVector2D(const QPointF& point) : xp(float(point.x())), yp(float(point.y())) {}
|
||||
|
||||
inline bool QVector2D::isNull() const
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ Q_DECL_CONSTEXPR inline QVector3D::QVector3D() : xp(0.0f), yp(0.0f), zp(0.0f) {}
|
||||
|
||||
Q_DECL_CONSTEXPR inline QVector3D::QVector3D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
|
||||
|
||||
Q_DECL_CONSTEXPR inline QVector3D::QVector3D(const QPointF& point) : xp(point.x()), yp(point.y()), zp(0.0f) {}
|
||||
Q_DECL_CONSTEXPR inline QVector3D::QVector3D(const QPointF& point) : xp(float(point.x())), yp(float(point.y())), zp(0.0f) {}
|
||||
|
||||
inline bool QVector3D::isNull() const
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ Q_DECL_CONSTEXPR inline QVector4D::QVector4D(float xpos, float ypos, float zpos,
|
||||
|
||||
Q_DECL_CONSTEXPR inline QVector4D::QVector4D(const QPoint& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
|
||||
|
||||
Q_DECL_CONSTEXPR inline QVector4D::QVector4D(const QPointF& point) : xp(point.x()), yp(point.y()), zp(0.0f), wp(0.0f) {}
|
||||
Q_DECL_CONSTEXPR inline QVector4D::QVector4D(const QPointF& point) : xp(float(point.x())), yp(float(point.y())), zp(0.0f), wp(0.0f) {}
|
||||
|
||||
inline bool QVector4D::isNull() const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user