From 76d6758a8d6f5136d5eba63e787fbf27ed5450e5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Sep 2022 10:08:16 +0200 Subject: shiboken6/test: Fix warnings about implicitly generated assignment operators Fix warnings like: warning: implicitly-declared constexpr Pen& Pen::operator=(const Pen&) is deprecated [-Wdeprecated-copy] by removing definitions of copy constructors/assignment operators which are equivalent to the default generated ones or spell out the special methods were needed. Change-Id: Ie7cb335707f8bdd297b0ceea969909bc809016d7 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit f419206841764323c244bf91051b2878451c17b6) Reviewed-by: Qt Cherry-pick Bot --- sources/shiboken6/tests/libsample/bytearray.cpp | 7 ------- sources/shiboken6/tests/libsample/bytearray.h | 1 - sources/shiboken6/tests/libsample/filter.cpp | 10 ---------- sources/shiboken6/tests/libsample/filter.h | 6 ++---- sources/shiboken6/tests/libsample/list.h | 18 +++++++++++++++--- sources/shiboken6/tests/libsample/listuser.cpp | 7 +++++++ sources/shiboken6/tests/libsample/listuser.h | 9 ++++++--- sources/shiboken6/tests/libsample/modelindex.h | 20 +++++++++++--------- sources/shiboken6/tests/libsample/pen.cpp | 4 ++++ sources/shiboken6/tests/libsample/pen.h | 5 ++++- sources/shiboken6/tests/libsample/str.cpp | 9 --------- sources/shiboken6/tests/libsample/str.h | 2 -- sources/shiboken6/tests/libsample/strlist.h | 6 +++++- sources/shiboken6/tests/libsample/valueandvirtual.h | 1 - sources/shiboken6/tests/libsmart/smart.cpp | 6 ++---- sources/shiboken6/tests/libsmart/smart_integer.h | 3 ++- 16 files changed, 58 insertions(+), 56 deletions(-) diff --git a/sources/shiboken6/tests/libsample/bytearray.cpp b/sources/shiboken6/tests/libsample/bytearray.cpp index 021d2a079..ee1e1ca93 100644 --- a/sources/shiboken6/tests/libsample/bytearray.cpp +++ b/sources/shiboken6/tests/libsample/bytearray.cpp @@ -57,13 +57,6 @@ ByteArray::ByteArray(const char* data, int len) m_data[len] = '\0'; } -ByteArray::ByteArray(const ByteArray& other) -{ - m_data = std::vector(other.size() + 1); - memcpy(&m_data[0], &other.m_data[0], other.size()); - m_data[other.size()] = '\0'; -} - int ByteArray::size() const { diff --git a/sources/shiboken6/tests/libsample/bytearray.h b/sources/shiboken6/tests/libsample/bytearray.h index 5dfb63fd5..a6bb4c6c6 100644 --- a/sources/shiboken6/tests/libsample/bytearray.h +++ b/sources/shiboken6/tests/libsample/bytearray.h @@ -40,7 +40,6 @@ public: ByteArray(char data); ByteArray(const char* data); ByteArray(const char* data, int len); - ByteArray(const ByteArray& other); int size() const; char at(int i) const; diff --git a/sources/shiboken6/tests/libsample/filter.cpp b/sources/shiboken6/tests/libsample/filter.cpp index f862babd2..c92e1f084 100644 --- a/sources/shiboken6/tests/libsample/filter.cpp +++ b/sources/shiboken6/tests/libsample/filter.cpp @@ -43,11 +43,6 @@ Union::Union(const Intersection& filter) m_filters.push_back(filter); } -Union::Union(const Union& filter) -{ - m_filters = filter.filters(); -} - Intersection::Intersection(const Data& filter) { m_filters.push_back(filter); @@ -58,11 +53,6 @@ Intersection::Intersection(const Union& filter) m_filters.push_back(filter); } -Intersection::Intersection(const Intersection& filter) -{ - m_filters = filter.filters(); -} - Intersection operator&(const Intersection& a, const Intersection& b) { Intersection filter; diff --git a/sources/shiboken6/tests/libsample/filter.h b/sources/shiboken6/tests/libsample/filter.h index e318cba20..298441d4f 100644 --- a/sources/shiboken6/tests/libsample/filter.h +++ b/sources/shiboken6/tests/libsample/filter.h @@ -66,8 +66,7 @@ public: Union(const Data&); Union(const Intersection&); - Union() {}; - Union(const Union&); + Union() = default; std::list filters() const { return m_filters; } void addFilter(const Filter& data) { m_filters.push_back(data); } @@ -82,8 +81,7 @@ public: Intersection(const Data&); Intersection(const Union&); - Intersection() {}; - Intersection(const Intersection&); + Intersection() = default; std::list filters() const { return m_filters; } void addFilter(const Filter& data) { m_filters.push_back(data); } diff --git a/sources/shiboken6/tests/libsample/list.h b/sources/shiboken6/tests/libsample/list.h index f4970d947..e44567a73 100644 --- a/sources/shiboken6/tests/libsample/list.h +++ b/sources/shiboken6/tests/libsample/list.h @@ -52,9 +52,13 @@ public: inline IntList() : m_ctorUsed(NoParamsCtor) {} inline explicit IntList(int val) : m_ctorUsed(IntCtor) { push_back(val); } - inline IntList(const IntList& lst) : List(lst), m_ctorUsed(CopyCtor) {} inline IntList(const List& lst) : List(lst), m_ctorUsed(ListOfIntCtor) {} + inline IntList(const IntList& lst) : List(lst), m_ctorUsed(CopyCtor) {} + IntList(IntList &&) = default; + IntList &operator=(const IntList &) = default; + IntList &operator=(IntList &&) = default; + inline void append(int v) { insert(end(), v); } CtorEnum constructorUsed() { return m_ctorUsed; } private: @@ -73,9 +77,13 @@ public: inline PointValueList() : m_ctorUsed(NoParamsCtor) {} inline explicit PointValueList(Point val) : m_ctorUsed(PointCtor) { push_back(val); } - inline PointValueList(const PointValueList& lst) : List(lst), m_ctorUsed(CopyCtor) {} inline PointValueList(const List& lst) : List(lst), m_ctorUsed(ListOfPointValuesCtor) {} + inline PointValueList(const PointValueList& lst) : List(lst), m_ctorUsed(CopyCtor) {} + PointValueList(PointValueList &&) = default; + PointValueList &operator=(const PointValueList &) = default; + PointValueList &operator=(PointValueList &&) = default; + inline void append(Point v) { insert(end(), v); } CtorEnum constructorUsed() { return m_ctorUsed; } private: @@ -94,9 +102,13 @@ public: inline ObjectTypePtrList() : m_ctorUsed(NoParamsCtor) {} inline explicit ObjectTypePtrList(ObjectType* val) : m_ctorUsed(ObjectTypeCtor) { push_back(val); } - inline ObjectTypePtrList(const ObjectTypePtrList& lst) : List(lst), m_ctorUsed(CopyCtor) {} inline ObjectTypePtrList(const List& lst) : List(lst), m_ctorUsed(ListOfObjectTypePtrCtor) {} + inline ObjectTypePtrList(const ObjectTypePtrList& lst) : List(lst), m_ctorUsed(CopyCtor) {} + ObjectTypePtrList(ObjectTypePtrList &&) = default; + ObjectTypePtrList &operator=(const ObjectTypePtrList &) = default; + ObjectTypePtrList &operator=(ObjectTypePtrList &&) = default; + inline void append(ObjectType* v) { insert(end(), v); } CtorEnum constructorUsed() { return m_ctorUsed; } private: diff --git a/sources/shiboken6/tests/libsample/listuser.cpp b/sources/shiboken6/tests/libsample/listuser.cpp index 995220b6f..d442975c3 100644 --- a/sources/shiboken6/tests/libsample/listuser.cpp +++ b/sources/shiboken6/tests/libsample/listuser.cpp @@ -38,6 +38,13 @@ ListUser::callCreateList() return createList(); } +ListUser::ListUser() = default; +ListUser::ListUser(const ListUser &other) = default; +ListUser::ListUser(ListUser &&other) = default; +ListUser &ListUser::operator=(const ListUser &other) = default; +ListUser &ListUser::operator=(ListUser &&other) = default; +ListUser::~ListUser() = default; + std::list ListUser::createList() { diff --git a/sources/shiboken6/tests/libsample/listuser.h b/sources/shiboken6/tests/libsample/listuser.h index 7e67039d9..9596de2c7 100644 --- a/sources/shiboken6/tests/libsample/listuser.h +++ b/sources/shiboken6/tests/libsample/listuser.h @@ -46,9 +46,12 @@ public: ListOfPointF }; - ListUser() {} - ListUser(const ListUser& other) : m_lst(other.m_lst) {} - virtual ~ListUser() {} + ListUser(); + ListUser(const ListUser &other); + ListUser(ListUser &&other); + ListUser &operator=(const ListUser &other); + ListUser &operator=(ListUser &&other); + virtual ~ListUser(); virtual std::list createList(); std::list callCreateList(); diff --git a/sources/shiboken6/tests/libsample/modelindex.h b/sources/shiboken6/tests/libsample/modelindex.h index dd3ddc089..370b1bce3 100644 --- a/sources/shiboken6/tests/libsample/modelindex.h +++ b/sources/shiboken6/tests/libsample/modelindex.h @@ -34,21 +34,22 @@ class ModelIndex { public: - ModelIndex() : m_value(0) {} - ModelIndex(const ModelIndex& other) { m_value = other.m_value; } + ModelIndex() = default; + inline void setValue(int value) { m_value = value; } inline int value() const { return m_value; } static int getValue(const ModelIndex& index) { return index.value(); } private: - int m_value; + int m_value = 0; }; class ReferentModelIndex { public: - ReferentModelIndex() {} - ReferentModelIndex(const ModelIndex& index) : m_index(index) {} - ReferentModelIndex(const ReferentModelIndex& other) { m_index = other.m_index; } + ReferentModelIndex() = default; + + explicit ReferentModelIndex(const ModelIndex& index) : m_index(index) {} + inline void setValue(int value) { m_index.setValue(value); } inline int value() const { return m_index.value(); } operator const ModelIndex&() const { return m_index; } @@ -59,9 +60,10 @@ private: class PersistentModelIndex { public: - PersistentModelIndex() {} - PersistentModelIndex(const ModelIndex& index) : m_index(index) {} - PersistentModelIndex(const PersistentModelIndex& other) { m_index = other.m_index; } + PersistentModelIndex() = default; + + explicit PersistentModelIndex(const ModelIndex& index) : m_index(index) {} + inline void setValue(int value) { m_index.setValue(value); } inline int value() const { return m_index.value(); } operator ModelIndex() const { return m_index; } diff --git a/sources/shiboken6/tests/libsample/pen.cpp b/sources/shiboken6/tests/libsample/pen.cpp index b5c9356d6..e4b989329 100644 --- a/sources/shiboken6/tests/libsample/pen.cpp +++ b/sources/shiboken6/tests/libsample/pen.cpp @@ -86,6 +86,10 @@ Pen::Pen(const Pen& pen) : m_ctor(CopyCtor) { } +Pen::Pen(Pen &&) = default; +Pen &Pen::operator=(const Pen& pen) = default; +Pen &Pen::operator=(Pen &&) = default; + int Pen::ctorType() { return m_ctor; diff --git a/sources/shiboken6/tests/libsample/pen.h b/sources/shiboken6/tests/libsample/pen.h index 3e4fe5dd8..d66e5fd9e 100644 --- a/sources/shiboken6/tests/libsample/pen.h +++ b/sources/shiboken6/tests/libsample/pen.h @@ -74,7 +74,10 @@ public: Pen(); Pen(SampleNamespace::Option option); Pen(const Color& color); - Pen(const Pen& pen); + Pen(const Pen &pen); + Pen(Pen &&); + Pen &operator=(const Pen &pen); + Pen &operator=(Pen &&); // PYSIDE-1325, default initializer void drawLine(int x1, int y1, int x2, int y2, RenderHints renderHints = {}); diff --git a/sources/shiboken6/tests/libsample/str.cpp b/sources/shiboken6/tests/libsample/str.cpp index 0411569b2..5f1bc3b37 100644 --- a/sources/shiboken6/tests/libsample/str.cpp +++ b/sources/shiboken6/tests/libsample/str.cpp @@ -34,11 +34,6 @@ using namespace std; -Str::Str(const Str& s) -{ - init(s.cstring()); -} - Str::Str(char c) { char str[2] = { c, 0 }; @@ -57,10 +52,6 @@ Str::init(const char* cstr) m_str = cstr; } -Str::~Str() -{ -} - Str Str::arg(const Str& s) const { diff --git a/sources/shiboken6/tests/libsample/str.h b/sources/shiboken6/tests/libsample/str.h index 2f7cee8c3..38b23eecb 100644 --- a/sources/shiboken6/tests/libsample/str.h +++ b/sources/shiboken6/tests/libsample/str.h @@ -35,10 +35,8 @@ class LIBSAMPLE_API Str { public: - Str(const Str& s); Str(char c); Str(const char* cstr = ""); - ~Str(); Str arg(const Str& s) const; diff --git a/sources/shiboken6/tests/libsample/strlist.h b/sources/shiboken6/tests/libsample/strlist.h index 43aa15390..e9dcaca04 100644 --- a/sources/shiboken6/tests/libsample/strlist.h +++ b/sources/shiboken6/tests/libsample/strlist.h @@ -46,9 +46,13 @@ public: inline StrList() : m_ctorUsed(NoParamsCtor) {} inline explicit StrList(const Str& str) : m_ctorUsed(StrCtor) { push_back(str); } - inline StrList(const StrList& lst) : std::list(lst), m_ctorUsed(CopyCtor) {} inline StrList(const std::list& lst) : std::list(lst), m_ctorUsed(ListOfStrCtor) {} + inline StrList(const StrList &lst) : std::list(lst), m_ctorUsed(CopyCtor) {} + StrList(StrList &&) = default; + StrList &operator=(const StrList &) = default; + StrList &operator=(StrList &&) = default; + inline void append(Str str) { push_back(str); } Str join(const Str& sep) const; diff --git a/sources/shiboken6/tests/libsample/valueandvirtual.h b/sources/shiboken6/tests/libsample/valueandvirtual.h index 34a6788e2..85676847d 100644 --- a/sources/shiboken6/tests/libsample/valueandvirtual.h +++ b/sources/shiboken6/tests/libsample/valueandvirtual.h @@ -33,7 +33,6 @@ class ValueAndVirtual { public: ValueAndVirtual(int id) : m_id(id) {} - ValueAndVirtual(const ValueAndVirtual &other) { m_id = other.m_id; } bool operator()(int id, int id2) { return id == id2; } diff --git a/sources/shiboken6/tests/libsmart/smart.cpp b/sources/shiboken6/tests/libsmart/smart.cpp index 09e1274de..8b142a910 100644 --- a/sources/shiboken6/tests/libsmart/smart.cpp +++ b/sources/shiboken6/tests/libsmart/smart.cpp @@ -293,7 +293,5 @@ Smart::Integer2::Integer2() { } -Smart::Integer2::Integer2(const Smart::Integer2 &other) - : Integer (other) -{ -} +Smart::Integer2::Integer2(const Smart::Integer2 &) = default; +Smart::Integer2 &Smart::Integer2::operator=(const Integer2 &) = default; diff --git a/sources/shiboken6/tests/libsmart/smart_integer.h b/sources/shiboken6/tests/libsmart/smart_integer.h index 0f2dfcec9..a9ee6b1c4 100644 --- a/sources/shiboken6/tests/libsmart/smart_integer.h +++ b/sources/shiboken6/tests/libsmart/smart_integer.h @@ -81,7 +81,8 @@ namespace Smart { class LIB_SMART_API Integer2 : public Integer { public: Integer2(); - Integer2(const Integer2 &other); + Integer2(const Integer2 &); + Integer2 &operator=(const Integer2 &); }; } // namespace Smart -- cgit v1.2.3