Skip to content

Commit

Permalink
Avoid new warning C5267 for deprecated implicit copy ctor/assign (#3497)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej committed Feb 26, 2023
1 parent 7f25cb3 commit c90b84a
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 8 deletions.
12 changes: 7 additions & 5 deletions stl/inc/bitset
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public:
friend bitset<_Bits>;

public:
_CONSTEXPR23 reference(const reference&) = default;

_CONSTEXPR23 ~reference() noexcept {} // TRANSITION, ABI

_CONSTEXPR23 reference& operator=(const bool _Val) noexcept {
Expand All @@ -44,11 +46,6 @@ public:
return *this;
}

_CONSTEXPR23 reference& flip() noexcept {
_Pbitset->_Flip_unchecked(_Mypos);
return *this;
}

_NODISCARD _CONSTEXPR23 bool operator~() const noexcept {
return !_Pbitset->_Subscript(_Mypos);
}
Expand All @@ -57,6 +54,11 @@ public:
return _Pbitset->_Subscript(_Mypos);
}

_CONSTEXPR23 reference& flip() noexcept {
_Pbitset->_Flip_unchecked(_Mypos);
return *this;
}

private:
_CONSTEXPR23 reference() noexcept : _Pbitset(nullptr), _Mypos(0) {}

Expand Down
2 changes: 2 additions & 0 deletions tests/std/tests/Dev08_576265_list_remove/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ struct Val {
unsigned int canary;
Val() : value(0), canary(0xDEADBEEF) {}
Val(int val) : value(val), canary(0x600DF00D) {}
Val(const Val&) = default;
Val& operator=(const Val&) = default;
~Val() {
canary = 0xDEADBEEF;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/std/tests/Dev11_0437519_container_behavior/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ void assert_forward_list_resize_empty() {

struct A {
A(unsigned int value) : _value(value) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {
_value = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct has_default {
has_default(const has_default& v) : x(v.x) {
++has_default_objects;
}
has_default& operator=(const has_default&) = default;

~has_default() {
--has_default_objects;
Expand All @@ -38,6 +39,7 @@ struct no_default {
no_default(const no_default& v) : x(v.x) {
++no_default_objects;
}
no_default& operator=(const no_default&) = default;

~no_default() {
--no_default_objects;
Expand Down
6 changes: 6 additions & 0 deletions tests/std/tests/P0220R1_any/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,8 @@ namespace modifiers::emplace {
struct Tracked {
static int count;
Tracked() {++count;}
Tracked(Tracked const&) noexcept {++count;}
Tracked& operator=(Tracked const&) = default;
~Tracked() { --count; }
};
int Tracked::count = 0;
Expand Down Expand Up @@ -2976,6 +2978,10 @@ namespace msvc {
Tracked() {
++count;
}
Tracked(Tracked const&) noexcept {
++count;
}
Tracked& operator=(Tracked const&) = default;
~Tracked() {
--count;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/std/tests/P0220R1_optional/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,8 @@ class Y
static bool dtor_called;
Y() = default;
Y(int) { TEST_THROW(6);}
Y(const Y&) = default;
Y& operator=(const Y&) = default;
~Y() {dtor_called = true;}
};

Expand Down Expand Up @@ -2659,6 +2661,8 @@ class X
constexpr X(int i, bool& dtor_called) : i_(i), dtor_called_(&dtor_called) {}
constexpr X(std::initializer_list<int> il, bool& dtor_called)
: i_(il.begin()[0]), j_(il.begin()[1]), dtor_called_(&dtor_called) {}
X(const X&) = default;
X& operator=(const X&) = default;
TEST_CONSTEXPR_CXX20 ~X() {*dtor_called_ = true;}

friend constexpr bool operator==(const X& x, const X& y)
Expand Down Expand Up @@ -2688,6 +2692,8 @@ class Z
Z(int i) : i_(i) {}
Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
{ TEST_THROW(6);}
Z(const Z&) = default;
Z& operator=(const Z&) = default;
~Z() {dtor_called = true;}

friend bool operator==(const Z& x, const Z& y)
Expand Down Expand Up @@ -5336,6 +5342,8 @@ class X
public:
static bool dtor_called;
X() = default;
X(const X&) = default;
X& operator=(const X&) = default;
~X() {dtor_called = true;}
};

Expand Down Expand Up @@ -5401,6 +5409,9 @@ using std::optional;
struct X
{
static bool dtor_called;
X() = default;
X(const X&) = default;
X& operator=(const X&) = default;
~X() {dtor_called = true;}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct double_double {
};
struct convertible_bool {
convertible_bool(bool x) : x_(x) {}
~convertible_bool() = default;

operator bool() const noexcept {
return x_;
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/P0674R1_make_shared_for_arrays/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,10 @@ struct WeirdDeleter {
delete ptr;
}

WeirdDeleter() = default;
WeirdDeleter(const WeirdDeleter&) = default;
WeirdDeleter& operator=(const WeirdDeleter&) = default;

~WeirdDeleter() noexcept(false) {}
};
static_assert(!is_nothrow_destructible_v<WeirdDeleter<int>>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,19 @@ template <class T>
struct A {
T value;

constexpr A() noexcept = default;
constexpr ~A() = default;
constexpr A() noexcept = default;
constexpr A(const A&) noexcept = default;
constexpr A& operator=(const A&) noexcept = default;
constexpr ~A() = default;
};

template <class T>
struct nontrivial_A {
T value;

constexpr nontrivial_A(T in = T{}) noexcept : value(in) {}
constexpr nontrivial_A(const nontrivial_A&) noexcept = default;
constexpr nontrivial_A& operator=(const nontrivial_A&) noexcept = default;
constexpr ~nontrivial_A() {}
};

Expand Down
7 changes: 7 additions & 0 deletions tests/std/tests/P0896R4_views_join/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,13 @@ void test_non_trivially_destructible_type() { // COMPILE-ONLY
using difference_type = int;
using value_type = int;

// Provide some way to construct this type.
non_trivially_destructible_input_iterator(double, double) {}

non_trivially_destructible_input_iterator(const non_trivially_destructible_input_iterator&) = default;
non_trivially_destructible_input_iterator& operator=(
const non_trivially_destructible_input_iterator&) = default;

~non_trivially_destructible_input_iterator() {}

// To test the correct specialization of _Defaultabox, this type must not be default constructible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct With_nontrivial_destructor {
int _val = 0;
constexpr With_nontrivial_destructor(const int val) noexcept : _val(val) {}
constexpr With_nontrivial_destructor(initializer_list<int> vals) noexcept : _val(*vals.begin()) {}
With_nontrivial_destructor(const With_nontrivial_destructor&) = default;
With_nontrivial_destructor& operator=(const With_nontrivial_destructor&) = default;
constexpr ~With_nontrivial_destructor() {}

constexpr bool operator==(const int right) const noexcept {
Expand Down

0 comments on commit c90b84a

Please sign in to comment.