Skip to content

Commit

Permalink
Remove level 4 compiler warnings from MSVC.
Browse files Browse the repository at this point in the history
Task-number: QTBUG-7233

Change-Id: I52067e3a22e98a62fd87415906e54a54ff2d6b49
Reviewed-by: Kurt Pattyn <[email protected]>
Reviewed-by: Oliver Wolff <[email protected]>
Reviewed-by: Joerg Bornemann <[email protected]>
Reviewed-by: Dave McClelland
  • Loading branch information
davschul authored and The Qt Project committed Mar 15, 2014
1 parent c6e271d commit cc0636e
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/concurrent/qtconcurrentiteratekernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class Q_CONCURRENT_EXPORT BlockSizeManager
Median<double> controlPartElapsed;
Median<double> userPartElapsed;
int m_blockSize;

Q_DISABLE_COPY(BlockSizeManager)
};

template <typename T>
Expand Down
3 changes: 3 additions & 0 deletions src/corelib/global/qglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/corelib/kernel/qmetatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions src/corelib/kernel/qobject_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 16 additions & 8 deletions src/corelib/tools/qhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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); }
Expand Down Expand Up @@ -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>
Expand All @@ -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)
};


Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions src/corelib/tools/qlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -937,4 +942,8 @@ Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List)

QT_END_NAMESPACE

#ifdef Q_CC_MSVC
#pragma warning( pop )
#endif

#endif // QLIST_H
9 changes: 9 additions & 0 deletions src/corelib/tools/qmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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)
{
Expand Down
11 changes: 11 additions & 0 deletions src/corelib/tools/qstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/corelib/tools/qstringbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,33 @@ 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 <>
class QStringBuilder <QByteArray, QByteArray> : public QStringBuilderBase<QStringBuilder<QByteArray, QByteArray>, QByteArray>
{
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;
};


Expand Down
9 changes: 9 additions & 0 deletions src/corelib/tools/qvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down

0 comments on commit cc0636e

Please sign in to comment.