Fix -Wdeprecated-copy warnings

Implicit copy constructors or methods are considered deprecated for
classes that has one of the two or a destructor.

The warning is enabled with -Wextra in gcc 9

Change-Id: Ic9be654f2a142fb186a4d5a7d6b4f7d6f4e611d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Allan Sandfeld Jensen 2018-11-13 17:14:43 +01:00
parent 869459f3c8
commit ef05c48898
9 changed files with 44 additions and 19 deletions

View File

@ -90,14 +90,8 @@ clang {
greaterThan(QT_GCC_MAJOR_VERSION, 5): QMAKE_CXXFLAGS_WARN_ON += -Wshift-overflow=2 -Wduplicated-cond greaterThan(QT_GCC_MAJOR_VERSION, 5): QMAKE_CXXFLAGS_WARN_ON += -Wshift-overflow=2 -Wduplicated-cond
# GCC 7 has a lot of false positives relating to this, so disable completely # GCC 7 has a lot of false positives relating to this, so disable completely
greaterThan(QT_GCC_MAJOR_VERSION, 6): QMAKE_CXXFLAGS_WARN_ON += -Wno-stringop-overflow greaterThan(QT_GCC_MAJOR_VERSION, 6): QMAKE_CXXFLAGS_WARN_ON += -Wno-stringop-overflow
# GCC 9 has a lot of false positives relating to this, so disable completely # GCC 9 introduced -Wformat-overflow in -Wall, but it is buggy:
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-copy
# GCC 9 introduced this
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-redundant-move
# GCC 9 introduced this
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-format-overflow greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-format-overflow
# GCC 9 introduced this
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-init-list-lifetime
} }
warnings_are_errors:warning_clean { warnings_are_errors:warning_clean {
@ -137,14 +131,13 @@ warnings_are_errors:warning_clean {
# GCC 7 includes -Wimplicit-fallthrough in -Wextra, but Qt is not yet free of implicit fallthroughs. # GCC 7 includes -Wimplicit-fallthrough in -Wextra, but Qt is not yet free of implicit fallthroughs.
greaterThan(QT_GCC_MAJOR_VERSION, 6): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=implicit-fallthrough greaterThan(QT_GCC_MAJOR_VERSION, 6): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=implicit-fallthrough
# GCC 9 has a lot of false positives relating to this, so disable completely # GCC 9 introduced -Wdeprecated-copy in -Wextra, but we are not clean for it.
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-deprecated-copy greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=deprecated-copy
# GCC 9 introduced this # GCC 9 introduced this
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-redundant-move greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=redundant-move
# GCC 9 introduced this # GCC 9 introduced this
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-format-overflow greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-error=init-list-lifetime
# GCC 9 introduced this
greaterThan(QT_GCC_MAJOR_VERSION, 8): QMAKE_CXXFLAGS_WARN_ON += -Wno-init-list-lifetime
# Work-around for bug https://code.google.com/p/android/issues/detail?id=58135 # Work-around for bug https://code.google.com/p/android/issues/detail?id=58135
android: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=literal-suffix android: QMAKE_CXXFLAGS_WARN_ON += -Wno-error=literal-suffix
} }

View File

@ -108,8 +108,7 @@ using QProcEnvKey = QByteArray;
class QProcEnvValue class QProcEnvValue
{ {
public: public:
QProcEnvValue() {} QProcEnvValue() = default;
QProcEnvValue(const QProcEnvValue &other) { *this = other; }
explicit QProcEnvValue(const QString &value) : stringValue(value) {} explicit QProcEnvValue(const QString &value) : stringValue(value) {}
explicit QProcEnvValue(const QByteArray &value) : byteValue(value) {} explicit QProcEnvValue(const QByteArray &value) : byteValue(value) {}
bool operator==(const QProcEnvValue &other) const bool operator==(const QProcEnvValue &other) const

View File

@ -398,10 +398,13 @@ class Q_CORE_EXPORT QVariant
: type(variantType), is_shared(false), is_null(false) : type(variantType), is_shared(false), is_null(false)
{} {}
inline Private(const Private &other) Q_DECL_NOTHROW #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Private(const Private &other) Q_DECL_NOTHROW
: data(other.data), type(other.type), : data(other.data), type(other.type),
is_shared(other.is_shared), is_null(other.is_null) is_shared(other.is_shared), is_null(other.is_null)
{} {}
Private &operator=(const Private &other) Q_DECL_NOTHROW = default;
#endif
union Data union Data
{ {
char c; char c;

View File

@ -67,7 +67,7 @@ template <> struct QListSpecialMethods<QByteArray>
{ {
#ifndef Q_CLANG_QDOC #ifndef Q_CLANG_QDOC
protected: protected:
~QListSpecialMethods() {} ~QListSpecialMethods() = default;
#endif #endif
public: public:
inline QByteArray join() const inline QByteArray join() const

View File

@ -73,7 +73,7 @@ template <typename T> class QSet;
template <typename T> struct QListSpecialMethods template <typename T> struct QListSpecialMethods
{ {
protected: protected:
~QListSpecialMethods() {} ~QListSpecialMethods() = default;
}; };
template <> struct QListSpecialMethods<QByteArray>; template <> struct QListSpecialMethods<QByteArray>;
template <> struct QListSpecialMethods<QString>; template <> struct QListSpecialMethods<QString>;
@ -249,6 +249,8 @@ public:
// can't remove it in Qt 5, since doing so would make the type trivial, // can't remove it in Qt 5, since doing so would make the type trivial,
// which changes the way it's passed to functions by value. // which changes the way it's passed to functions by value.
inline iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i){} inline iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i){}
inline iterator &operator=(const iterator &o) Q_DECL_NOTHROW
{ i = o.i; return *this; }
#endif #endif
inline T &operator*() const { return i->t(); } inline T &operator*() const { return i->t(); }
inline T *operator->() const { return &i->t(); } inline T *operator->() const { return &i->t(); }
@ -302,6 +304,8 @@ public:
// can't remove it in Qt 5, since doing so would make the type trivial, // can't remove it in Qt 5, since doing so would make the type trivial,
// which changes the way it's passed to functions by value. // which changes the way it's passed to functions by value.
inline const_iterator(const const_iterator &o) Q_DECL_NOTHROW : i(o.i) {} inline const_iterator(const const_iterator &o) Q_DECL_NOTHROW : i(o.i) {}
inline const_iterator &operator=(const const_iterator &o) Q_DECL_NOTHROW
{ i = o.i; return *this; }
#endif #endif
#ifdef QT_STRICT_ITERATORS #ifdef QT_STRICT_ITERATORS
inline explicit const_iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i) {} inline explicit const_iterator(const iterator &o) Q_DECL_NOTHROW : i(o.i) {}

View File

@ -66,7 +66,7 @@ template <> struct QListSpecialMethods<QString>
{ {
#ifndef Q_QDOC #ifndef Q_QDOC
protected: protected:
~QListSpecialMethods() {} ~QListSpecialMethods() = default;
#endif #endif
public: public:
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive); inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);

View File

@ -93,6 +93,8 @@ public:
return indices16.size(); return indices16.size();
} }
QVertexIndexVector() = default;
QVertexIndexVector(const QVertexIndexVector &other) = default;
inline QVertexIndexVector &operator = (const QVertexIndexVector &other) inline QVertexIndexVector &operator = (const QVertexIndexVector &other)
{ {
if (t == UnsignedInt) if (t == UnsignedInt)

View File

@ -263,6 +263,7 @@ public:
iterator() : p(nullptr), b(0), e(0), n(0) {} iterator() : p(nullptr), b(0), e(0), n(0) {}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0) #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
iterator(const iterator &o) : p(o.p), b(o.b), e(o.e), n(o.n) {} iterator(const iterator &o) : p(o.p), b(o.b), e(o.e), n(o.n) {}
iterator &operator=(const iterator &o) = default;
#endif #endif
QTextFragment fragment() const; QTextFragment fragment() const;

View File

@ -118,6 +118,7 @@ public:
QStyleOptionFocusRect(); QStyleOptionFocusRect();
QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionFocusRect &operator=(const QStyleOptionFocusRect &other) = default;
protected: protected:
QStyleOptionFocusRect(int version); QStyleOptionFocusRect(int version);
@ -142,6 +143,7 @@ public:
QStyleOptionFrame(); QStyleOptionFrame();
QStyleOptionFrame(const QStyleOptionFrame &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionFrame(const QStyleOptionFrame &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionFrame &operator=(const QStyleOptionFrame &other) = default;
protected: protected:
QStyleOptionFrame(int version); QStyleOptionFrame(int version);
@ -171,6 +173,7 @@ public:
QStyleOptionTabWidgetFrame(); QStyleOptionTabWidgetFrame();
inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other) inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other)
: QStyleOption(Version, Type) { *this = other; } : QStyleOption(Version, Type) { *this = other; }
QStyleOptionTabWidgetFrame &operator=(const QStyleOptionTabWidgetFrame &other) = default;
protected: protected:
QStyleOptionTabWidgetFrame(int version); QStyleOptionTabWidgetFrame(int version);
@ -194,6 +197,7 @@ public:
QStyleOptionTabBarBase(); QStyleOptionTabBarBase();
QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionTabBarBase &operator=(const QStyleOptionTabBarBase &other) = default;
protected: protected:
QStyleOptionTabBarBase(int version); QStyleOptionTabBarBase(int version);
@ -225,6 +229,7 @@ public:
QStyleOptionHeader(); QStyleOptionHeader();
QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionHeader &operator=(const QStyleOptionHeader &other) = default;
protected: protected:
QStyleOptionHeader(int version); QStyleOptionHeader(int version);
@ -247,6 +252,7 @@ public:
QStyleOptionButton(); QStyleOptionButton();
QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionButton &operator=(const QStyleOptionButton &other) = default;
protected: protected:
QStyleOptionButton(int version); QStyleOptionButton(int version);
@ -284,6 +290,7 @@ public:
QStyleOptionTab(); QStyleOptionTab();
QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionTab &operator=(const QStyleOptionTab &other) = default;
protected: protected:
QStyleOptionTab(int version); QStyleOptionTab(int version);
@ -314,6 +321,7 @@ public:
int midLineWidth; int midLineWidth;
QStyleOptionToolBar(); QStyleOptionToolBar();
QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionToolBar &operator=(const QStyleOptionToolBar &other) = default;
protected: protected:
QStyleOptionToolBar(int version); QStyleOptionToolBar(int version);
@ -341,6 +349,7 @@ public:
QStyleOptionProgressBar(); QStyleOptionProgressBar();
QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionProgressBar &operator=(const QStyleOptionProgressBar &other) = default;
protected: protected:
QStyleOptionProgressBar(int version); QStyleOptionProgressBar(int version);
@ -371,6 +380,7 @@ public:
QStyleOptionMenuItem(); QStyleOptionMenuItem();
QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionMenuItem &operator=(const QStyleOptionMenuItem &other) = default;
protected: protected:
QStyleOptionMenuItem(int version); QStyleOptionMenuItem(int version);
@ -390,6 +400,7 @@ public:
QStyleOptionDockWidget(); QStyleOptionDockWidget();
QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionDockWidget &operator=(const QStyleOptionDockWidget &other) = default;
protected: protected:
QStyleOptionDockWidget(int version); QStyleOptionDockWidget(int version);
@ -441,6 +452,7 @@ public:
QStyleOptionViewItem(); QStyleOptionViewItem();
QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionViewItem &operator=(const QStyleOptionViewItem &other) = default;
protected: protected:
QStyleOptionViewItem(int version); QStyleOptionViewItem(int version);
@ -471,6 +483,7 @@ public:
QStyleOptionToolBox(); QStyleOptionToolBox();
QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionToolBox &operator=(const QStyleOptionToolBox &other) = default;
protected: protected:
QStyleOptionToolBox(int version); QStyleOptionToolBox(int version);
@ -490,6 +503,7 @@ public:
QStyleOptionRubberBand(); QStyleOptionRubberBand();
QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionRubberBand &operator=(const QStyleOptionRubberBand &other) = default;
protected: protected:
QStyleOptionRubberBand(int version); QStyleOptionRubberBand(int version);
@ -508,6 +522,7 @@ public:
QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex); QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex);
QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionComplex &operator=(const QStyleOptionComplex &other) = default;
}; };
#if QT_CONFIG(slider) #if QT_CONFIG(slider)
@ -532,6 +547,7 @@ public:
QStyleOptionSlider(); QStyleOptionSlider();
QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; } QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; }
QStyleOptionSlider &operator=(const QStyleOptionSlider &other) = default;
protected: protected:
QStyleOptionSlider(int version); QStyleOptionSlider(int version);
@ -551,6 +567,7 @@ public:
QStyleOptionSpinBox(); QStyleOptionSpinBox();
QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; } QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
QStyleOptionSpinBox &operator=(const QStyleOptionSpinBox &other) = default;
protected: protected:
QStyleOptionSpinBox(int version); QStyleOptionSpinBox(int version);
@ -578,6 +595,7 @@ public:
QStyleOptionToolButton(); QStyleOptionToolButton();
QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; } QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; }
QStyleOptionToolButton &operator=(const QStyleOptionToolButton &other) = default;
protected: protected:
QStyleOptionToolButton(int version); QStyleOptionToolButton(int version);
@ -600,6 +618,7 @@ public:
QStyleOptionComboBox(); QStyleOptionComboBox();
QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; } QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
QStyleOptionComboBox &operator=(const QStyleOptionComboBox &other) = default;
protected: protected:
QStyleOptionComboBox(int version); QStyleOptionComboBox(int version);
@ -618,6 +637,7 @@ public:
QStyleOptionTitleBar(); QStyleOptionTitleBar();
QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; } QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; }
QStyleOptionTitleBar &operator=(const QStyleOptionTitleBar &other) = default;
protected: protected:
QStyleOptionTitleBar(int version); QStyleOptionTitleBar(int version);
@ -638,6 +658,7 @@ public:
QStyleOptionGroupBox(); QStyleOptionGroupBox();
QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; } QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
QStyleOptionGroupBox &operator=(const QStyleOptionGroupBox &other) = default;
protected: protected:
QStyleOptionGroupBox(int version); QStyleOptionGroupBox(int version);
}; };
@ -652,6 +673,7 @@ public:
QStyleOptionSizeGrip(); QStyleOptionSizeGrip();
QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; } QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; }
QStyleOptionSizeGrip &operator=(const QStyleOptionSizeGrip &other) = default;
protected: protected:
QStyleOptionSizeGrip(int version); QStyleOptionSizeGrip(int version);
}; };
@ -668,6 +690,7 @@ public:
QStyleOptionGraphicsItem(); QStyleOptionGraphicsItem();
QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; } QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; }
QStyleOptionGraphicsItem &operator=(const QStyleOptionGraphicsItem &other) = default;
static qreal levelOfDetailFromTransform(const QTransform &worldTransform); static qreal levelOfDetailFromTransform(const QTransform &worldTransform);
protected: protected:
QStyleOptionGraphicsItem(int version); QStyleOptionGraphicsItem(int version);