Win: Account for when "condition expression is constant" warning occurs

There is already some case accounting for when this warning appears with
warning level 4 and Visual C++ on Windows. However it was not catching
all the places it was coming from, so this extends it to cover those
places too.

Change-Id: I69b21440716361fda1c1ae0be0d9c17ced7f0792
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Andy Shaw 2017-06-01 17:42:09 +02:00
parent 1e1a2c7397
commit 425aa282df

View File

@ -310,6 +310,7 @@ private:
// will be default-initialized // will be default-initialized
# pragma warning ( push ) # pragma warning ( push )
# pragma warning ( disable : 4345 ) # pragma warning ( disable : 4345 )
# pragma warning(disable : 4127) // conditional expression is constant
#endif #endif
template <typename T> template <typename T>
@ -324,10 +325,6 @@ void QVector<T>::defaultConstruct(T *from, T *to)
} }
} }
#ifdef Q_CC_MSVC
# pragma warning ( pop )
#endif
template <typename T> template <typename T>
void QVector<T>::copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom) void QVector<T>::copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom)
{ {
@ -339,11 +336,6 @@ void QVector<T>::copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom)
} }
} }
#if defined(Q_CC_MSVC)
#pragma warning( push )
#pragma warning( disable : 4127 ) // conditional expression is constant
#endif
template <typename T> template <typename T>
void QVector<T>::destruct(T *from, T *to) void QVector<T>::destruct(T *from, T *to)
{ {
@ -354,10 +346,6 @@ void QVector<T>::destruct(T *from, T *to)
} }
} }
#if defined(Q_CC_MSVC)
#pragma warning( pop )
#endif
template <typename T> template <typename T>
inline QVector<T>::QVector(const QVector<T> &v) inline QVector<T>::QVector(const QVector<T> &v)
{ {
@ -379,6 +367,10 @@ inline QVector<T>::QVector(const QVector<T> &v)
} }
} }
#if defined(Q_CC_MSVC)
#pragma warning( pop )
#endif
template <typename T> template <typename T>
void QVector<T>::detach() void QVector<T>::detach()
{ {
@ -506,6 +498,11 @@ QVector<T>::QVector(int asize, const T &t)
} }
#ifdef Q_COMPILER_INITIALIZER_LISTS #ifdef Q_COMPILER_INITIALIZER_LISTS
# if defined(Q_CC_MSVC)
QT_WARNING_PUSH
QT_WARNING_DISABLE_MSVC(4127) // conditional expression is constant
# endif // Q_CC_MSVC
template <typename T> template <typename T>
QVector<T>::QVector(std::initializer_list<T> args) QVector<T>::QVector(std::initializer_list<T> args)
{ {
@ -520,7 +517,10 @@ QVector<T>::QVector(std::initializer_list<T> args)
d = Data::sharedNull(); d = Data::sharedNull();
} }
} }
#endif # if defined(Q_CC_MSVC)
QT_WARNING_POP
# endif // Q_CC_MSVC
#endif // Q_COMPILER_INITALIZER_LISTS
template <typename T> template <typename T>
void QVector<T>::freeData(Data *x) void QVector<T>::freeData(Data *x)
@ -529,6 +529,11 @@ void QVector<T>::freeData(Data *x)
Data::deallocate(x); Data::deallocate(x);
} }
#if defined(Q_CC_MSVC)
QT_WARNING_PUSH
QT_WARNING_DISABLE_MSVC(4127) // conditional expression is constant
#endif
template <typename T> template <typename T>
void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::AllocationOptions options) void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::AllocationOptions options)
{ {
@ -620,6 +625,10 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
Q_ASSERT(d->size == asize); Q_ASSERT(d->size == asize);
} }
#if defined(Q_CC_MSVC)
QT_WARNING_POP
#endif
template<typename T> template<typename T>
Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i) const Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i) const
{ {