Remove level 4 compiler warnings from MSVC.

Task-number: QTBUG-7233

Change-Id: I52067e3a22e98a62fd87415906e54a54ff2d6b49
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: Dave McClelland
bb10
David Schulz 2014-03-07 13:18:31 +01:00 committed by The Qt Project
parent c6e271da6d
commit cc0636ea1e
10 changed files with 73 additions and 8 deletions

View File

@ -86,6 +86,8 @@ private:
Median<double> controlPartElapsed;
Median<double> userPartElapsed;
int m_blockSize;
Q_DISABLE_COPY(BlockSizeManager)
};
template <typename T>

View File

@ -881,8 +881,11 @@ struct QForeachContainerBase {};
template <typename T>
class QForeachContainer : public QForeachContainerBase {
QForeachContainer &operator=(const QForeachContainer &) Q_DECL_EQ_DELETE;
public:
inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){}
QForeachContainer(const QForeachContainer &other)
: c(other.c), brk(other.brk), i(other.i), e(other.e) {}
const T c;
mutable int brk;
mutable typename T::const_iterator i, e;

View File

@ -771,9 +771,13 @@ struct VariantData
, flags(flags_)
{
}
VariantData(const VariantData &other)
: metaTypeId(other.metaTypeId), data(other.data), flags(other.flags){}
const int metaTypeId;
const void *data;
const uint flags;
private:
VariantData &operator=(const VariantData &) Q_DECL_EQ_DELETE;
};
template<typename const_iterator>

View File

@ -132,6 +132,8 @@ namespace QtPrivate {
inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, 0); }
protected:
~QSlotObjectBase() {}
private:
Q_DISABLE_COPY(QSlotObjectBase)
};
// implementation of QSlotObjectBase for which the slot is a pointer to member function of a QObject
// Args and R are the List of arguments and the returntype of the signal to which the slot is connected.

View File

@ -52,6 +52,12 @@
#include <initializer_list>
#endif
#if defined(Q_CC_MSVC)
#pragma warning( push )
#pragma warning( disable : 4311 ) // disable pointer truncation warning
#pragma warning( disable : 4127 ) // conditional expression is constant
#endif
QT_BEGIN_NAMESPACE
class QBitArray;
@ -99,18 +105,10 @@ Q_CORE_EXPORT uint qHash(QLatin1String key, uint seed = 0) Q_DECL_NOTHROW;
Q_CORE_EXPORT uint qt_hash(const QString &key) Q_DECL_NOTHROW;
Q_CORE_EXPORT uint qt_hash(const QStringRef &key) Q_DECL_NOTHROW;
#if defined(Q_CC_MSVC)
#pragma warning( push )
#pragma warning( disable : 4311 ) // disable pointer truncation warning
#endif
template <class T> inline uint qHash(const T *key, uint seed = 0) Q_DECL_NOTHROW
{
return qHash(reinterpret_cast<quintptr>(key), seed);
}
#if defined(Q_CC_MSVC)
#pragma warning( pop )
#endif
template<typename T> inline uint qHash(const T &t, uint seed)
Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
{ return (qHash(t) ^ seed); }
@ -218,6 +216,9 @@ struct QHashNode
inline QHashNode(const Key &key0, const T &value0, uint hash, QHashNode *n)
: next(n), h(hash), key(key0), value(value0) {}
inline bool same_key(uint h0, const Key &key0) const { return h0 == h && key0 == key; }
private:
Q_DISABLE_COPY(QHashNode)
};
template <class Key, class T>
@ -228,6 +229,9 @@ struct QHashDummyNode
const Key key;
inline QHashDummyNode(const Key &key0, uint hash, QHashNode<Key, T> *n) : next(n), h(hash), key(key0) {}
private:
Q_DISABLE_COPY(QHashDummyNode)
};
@ -1091,4 +1095,8 @@ Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Hash)
QT_END_NAMESPACE
#if defined(Q_CC_MSVC)
#pragma warning( pop )
#endif
#endif // QHASH_H

View File

@ -58,6 +58,11 @@
#include <limits.h>
#include <string.h>
#ifdef Q_CC_MSVC
#pragma warning( push )
#pragma warning( disable : 4127 ) // "conditional expression is constant"
#endif
QT_BEGIN_NAMESPACE
@ -937,4 +942,8 @@ Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List)
QT_END_NAMESPACE
#ifdef Q_CC_MSVC
#pragma warning( pop )
#endif
#endif // QLIST_H

View File

@ -260,6 +260,11 @@ QMapNode<Key, T> *QMapNode<Key, T>::copy(QMapData<Key, T> *d) const
return n;
}
#if defined(Q_CC_MSVC)
#pragma warning( push )
#pragma warning( disable : 4127 ) // conditional expression is constant
#endif
template <class Key, class T>
void QMapNode<Key, T>::destroySubTree()
{
@ -275,6 +280,10 @@ void QMapNode<Key, T>::destroySubTree()
}
}
#if defined(Q_CC_MSVC)
#pragma warning( pop )
#endif
template <class Key, class T>
void QMapData<Key, T>::deleteNode(QMapNode<Key, T> *z)
{

View File

@ -870,6 +870,12 @@ inline QString QString::arg(const QString &a1, const QString &a2, const QString
inline QString QString::section(QChar asep, int astart, int aend, SectionFlags aflags) const
{ return section(QString(asep), astart, aend, aflags); }
#ifdef Q_CC_MSVC
// "conditional expression is constant"
#pragma warning(push)
#pragma warning(disable : 4127)
#endif
inline int QString::toWCharArray(wchar_t *array) const
{
if (sizeof(wchar_t) == sizeof(QChar)) {
@ -878,6 +884,11 @@ inline int QString::toWCharArray(wchar_t *array) const
}
return toUcs4_helper(d->data(), size(), reinterpret_cast<uint *>(array));
}
#ifdef Q_CC_MSVC
#pragma warning(pop)
#endif
inline QString QString::fromWCharArray(const wchar_t *string, int size)
{
return sizeof(wchar_t) == sizeof(QChar) ? fromUtf16(reinterpret_cast<const ushort *>(string), size)

View File

@ -143,12 +143,16 @@ class QStringBuilder <QString, QString> : public QStringBuilderBase<QStringBuild
{
public:
QStringBuilder(const QString &a_, const QString &b_) : a(a_), b(b_) {}
QStringBuilder(const QStringBuilder &other) : a(other.a), b(other.b) {}
operator QString() const
{ QString r(a); r += b; return r; }
const QString &a;
const QString &b;
private:
QStringBuilder &operator=(const QStringBuilder &) Q_DECL_EQ_DELETE;
};
template <>
@ -156,12 +160,16 @@ class QStringBuilder <QByteArray, QByteArray> : public QStringBuilderBase<QStrin
{
public:
QStringBuilder(const QByteArray &a_, const QByteArray &b_) : a(a_), b(b_) {}
QStringBuilder(const QStringBuilder &other) : a(other.a), b(other.b) {}
operator QByteArray() const
{ QByteArray r(a); r += b; return r; }
const QByteArray &a;
const QByteArray &b;
private:
QStringBuilder &operator=(const QStringBuilder &) Q_DECL_EQ_DELETE;
};

View File

@ -287,6 +287,11 @@ 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>
void QVector<T>::destruct(T *from, T *to)
{
@ -297,6 +302,10 @@ void QVector<T>::destruct(T *from, T *to)
}
}
#if defined(Q_CC_MSVC)
#pragma warning( pop )
#endif
template <typename T>
inline QVector<T>::QVector(const QVector<T> &v)
{