Add -Wdouble-promotion to headersclean

Fixes: warning: implicit conversion from 'float' to 'double' to match
other operand of binary expression [-Wdouble-promotion]

Task-number: QTBUG-57068
Change-Id: I897a341aca83873bc6abd256a82a3b9f09409833
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jesus Fernandez 2016-11-18 14:05:34 +01:00
parent 4a7f3c327b
commit 1e4054ce2f
3 changed files with 36 additions and 22 deletions

View File

@ -204,9 +204,20 @@ headersclean:!internal_module {
!contains(QT_ARCH, arm):!contains(QT_ARCH, mips): \
hcleanFLAGS += -Wcast-align
greaterThan(QT_CLANG_MAJOR_VERSION, 3) {
hcleanFLAGS += -Wdouble-promotion
} greaterThan(QT_CLANG_MAJOR_VERSION, 2):greaterThan(QT_CLANG_MINOR_VERSION, 7) {
hcleanFLAGS += -Wdouble-promotion
}
!clang {
# options accepted only by GCC
greaterThan(QT_GCC_MAJOR_VERSION, 4) {
hcleanFLAGS += -Wdouble-promotion
} greaterThan(QT_GCC_MAJOR_VERSION, 3):greaterThan(QT_GCC_MINOR_VERSION, 4) {
hcleanFLAGS += -Wdouble-promotion
}
c++11 {
# only enabled for actual c++11 builds due to
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52806

View File

@ -867,9 +867,9 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix)
yin * matrix.m[3][1] +
matrix.m[3][3];
if (w == 1.0f) {
return QPointF(float(x), float(y));
return QPointF(qreal(x), qreal(y));
} else {
return QPointF(float(x / w), float(y / w));
return QPointF(qreal(x / w), qreal(y / w));
}
}
@ -907,33 +907,35 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point)
inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point)
{
float xin, yin;
float x, y, w;
qreal xin, yin;
qreal x, y, w;
xin = point.x();
yin = point.y();
if (matrix.flagBits == QMatrix4x4::Identity) {
return point;
} else if (matrix.flagBits < QMatrix4x4::Rotation2D) {
// Translation | Scale
return QPointF(xin * matrix.m[0][0] + matrix.m[3][0],
yin * matrix.m[1][1] + matrix.m[3][1]);
return QPointF(xin * qreal(matrix.m[0][0]) + qreal(matrix.m[3][0]),
yin * qreal(matrix.m[1][1]) + qreal(matrix.m[3][1]));
} else if (matrix.flagBits < QMatrix4x4::Perspective) {
return QPointF(xin * matrix.m[0][0] + yin * matrix.m[1][0] + matrix.m[3][0],
xin * matrix.m[0][1] + yin * matrix.m[1][1] + matrix.m[3][1]);
return QPointF(xin * qreal(matrix.m[0][0]) + yin * qreal(matrix.m[1][0]) +
qreal(matrix.m[3][0]),
xin * qreal(matrix.m[0][1]) + yin * qreal(matrix.m[1][1]) +
qreal(matrix.m[3][1]));
} else {
x = xin * matrix.m[0][0] +
yin * matrix.m[1][0] +
matrix.m[3][0];
y = xin * matrix.m[0][1] +
yin * matrix.m[1][1] +
matrix.m[3][1];
w = xin * matrix.m[0][3] +
yin * matrix.m[1][3] +
matrix.m[3][3];
if (w == 1.0f) {
return QPointF(float(x), float(y));
x = xin * qreal(matrix.m[0][0]) +
yin * qreal(matrix.m[1][0]) +
qreal(matrix.m[3][0]);
y = xin * qreal(matrix.m[0][1]) +
yin * qreal(matrix.m[1][1]) +
qreal(matrix.m[3][1]);
w = xin * qreal(matrix.m[0][3]) +
yin * qreal(matrix.m[1][3]) +
qreal(matrix.m[3][3]);
if (w == 1.0) {
return QPointF(qreal(x), qreal(y));
} else {
return QPointF(float(x / w), float(y / w));
return QPointF(qreal(x / w), qreal(y / w));
}
}
}

View File

@ -202,7 +202,8 @@ inline QQuaternion QQuaternion::inverted() const
double(yp) * double(yp) +
double(zp) * double(zp);
if (!qFuzzyIsNull(len))
return QQuaternion(wp / len, -xp / len, -yp / len, -zp / len);
return QQuaternion(double(wp) / len, double(-xp) / len,
double(-yp) / len, double(-zp) / len);
return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f);
}
@ -251,7 +252,7 @@ inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2)
float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp);
float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp);
float xx = ww + yy + zz;
float qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
float qq = 0.5f * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp));
float w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp);
float x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp);