[libc++][test] Add '-Wdeprecated-copy', '-Wdeprecated-copy-dtor' warnings to the test suite

This is a follow up to https://reviews.llvm.org/D144694.
Fixes https://github.com/llvm/llvm-project/issues/60977.

Differential Revision: https://reviews.llvm.org/D144775
This commit is contained in:
Igor Zhukov
2023-09-08 11:15:53 -04:00
committed by Louis Dionne
parent ec0f678744
commit 70248920fc
36 changed files with 97 additions and 6 deletions

View File

@@ -72,7 +72,8 @@ public:
class _LIBCPP_EXPORTED_FROM_ABI exception {
public:
_LIBCPP_HIDE_FROM_ABI exception() _NOEXCEPT {}
_LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default;
virtual ~exception() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
@@ -81,6 +82,8 @@ public:
class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception {
public:
_LIBCPP_HIDE_FROM_ABI bad_exception() _NOEXCEPT {}
_LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default;
~bad_exception() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};

View File

@@ -33,8 +33,8 @@ class _LIBCPP_EXPORTED_FROM_ABI nested_exception {
public:
nested_exception() _NOEXCEPT;
// nested_exception(const nested_exception&) noexcept = default;
// nested_exception& operator=(const nested_exception&) noexcept = default;
_LIBCPP_HIDE_FROM_ABI nested_exception(const nested_exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI nested_exception& operator=(const nested_exception&) _NOEXCEPT = default;
virtual ~nested_exception() _NOEXCEPT;
// access functions

View File

@@ -928,6 +928,8 @@ private:
requires(is_trivially_move_constructible_v<_ValueType> && is_trivially_move_constructible_v<_ErrorType>)
union __union_t<_ValueType, _ErrorType> {
_LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
_LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default;
_LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default;
template <class _Func, class... _Args>
_LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(
@@ -1529,6 +1531,8 @@ private:
requires is_trivially_move_constructible_v<_ErrorType>
union __union_t<_ErrorType> {
_LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {}
_LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default;
_LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default;
template <class _Func, class... _Args>
_LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(

View File

@@ -30,6 +30,8 @@ public:
: runtime_error(__s) {}
_LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
: runtime_error(__s) {}
_LIBCPP_HIDE_FROM_ABI format_error(const format_error&) = default;
_LIBCPP_HIDE_FROM_ABI format_error& operator=(const format_error&) = default;
_LIBCPP_HIDE_FROM_ABI_VIRTUAL
~format_error() noexcept override = default;
};

View File

@@ -57,6 +57,9 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_function_call
: public exception
{
public:
_LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_function_call(const bad_function_call&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_function_call& operator=(const bad_function_call&) _NOEXCEPT = default;
// Note that when a key function is not used, every translation unit that uses
// bad_function_call will end up containing a weak definition of the vtable and
// typeinfo.

View File

@@ -126,6 +126,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr
public:
_LIBCPP_HIDE_FROM_ABI bad_weak_ptr() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_weak_ptr& operator=(const bad_weak_ptr&) _NOEXCEPT = default;
~bad_weak_ptr() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};

View File

@@ -133,6 +133,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_alloc
{
public:
bad_alloc() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default;
~bad_alloc() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
@@ -142,6 +144,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length
{
public:
bad_array_new_length() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default;
~bad_array_new_length() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};

View File

@@ -249,6 +249,9 @@ class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_opt
: public exception
{
public:
_LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_optional_access& operator=(const bad_optional_access&) _NOEXCEPT = default;
// Get the key function ~bad_optional_access() into the dylib
~bad_optional_access() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;

View File

@@ -129,6 +129,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default;
~domain_error() _NOEXCEPT override;
#endif
};
@@ -142,6 +143,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default;
~invalid_argument() _NOEXCEPT override;
#endif
};
@@ -154,6 +156,7 @@ public:
_LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default;
~length_error() _NOEXCEPT override;
#endif
};
@@ -167,6 +170,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default;
~out_of_range() _NOEXCEPT override;
#endif
};
@@ -180,6 +184,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default;
~range_error() _NOEXCEPT override;
#endif
};
@@ -193,6 +198,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default;
~overflow_error() _NOEXCEPT override;
#endif
};
@@ -206,6 +212,7 @@ public:
#ifndef _LIBCPP_ABI_VCRUNTIME
_LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default;
~underflow_error() _NOEXCEPT override;
#endif
};

View File

@@ -360,6 +360,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_cast
public:
bad_cast() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default;
~bad_cast() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};
@@ -369,6 +370,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_typeid
{
public:
bad_typeid() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default;
~bad_typeid() _NOEXCEPT override;
const char* what() const _NOEXCEPT override;
};

View File

@@ -29,6 +29,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}
int get() const {return data_;}
@@ -50,6 +52,8 @@ class B
int data_;
public:
B(int d=1) : data_(d) {}
B(const B&) = default;
B& operator=(const B&) = default;
~B() {data_ = -1;}
int get() const {return data_;}

View File

@@ -27,6 +27,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}
friend bool operator==(const A& x, const A& y)

View File

@@ -24,6 +24,8 @@ struct Node {
int* shared_val;
explicit Node(int* ptr) : shared_val(ptr) {}
Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() { ++(*shared_val); }
};

View File

@@ -26,6 +26,8 @@ struct Base {
explicit Base(char* buf, int* idx, char ch)
: shared_buff(buf), cur_idx(idx), id(ch) {}
Base(const Base& other) = default;
Base& operator=(const Base&) = delete;
~Base() { shared_buff[(*cur_idx)++] = id; }
};

View File

@@ -21,6 +21,8 @@ __attribute__((noinline)) void call_something() { asm volatile(""); }
struct Node {
explicit Node() {}
Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() {}
};

View File

@@ -21,6 +21,8 @@ __attribute__((noinline)) void call_something() { asm volatile(""); }
struct Node {
explicit Node() {}
Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() {}
};

View File

@@ -24,6 +24,9 @@ struct A
static std::function<void()> global;
static bool cancel;
A() = default;
A(const A&) = default;
A& operator=(const A&) = default;
~A() {
DoNotOptimize(cancel);
if (cancel)

View File

@@ -24,6 +24,9 @@ struct A
static std::function<void()> global;
static bool cancel;
A() = default;
A(const A&) = default;
A& operator=(const A&) = default;
~A() {
DoNotOptimize(cancel);
if (cancel)

View File

@@ -37,6 +37,8 @@ class Copyable
int data_;
public:
Copyable() : data_(0) {}
Copyable(const Copyable&) = default;
Copyable& operator=(const Copyable&) = default;
~Copyable() {data_ = -1;}
friend bool operator==(const Copyable& x, const Copyable& y)

View File

@@ -37,6 +37,8 @@ class Copyable
int data_;
public:
Copyable() : data_(0) {}
Copyable(const Copyable&) = default;
Copyable& operator=(const Copyable&) = default;
~Copyable() {data_ = -1;}
friend bool operator==(const Copyable& x, const Copyable& y)

View File

@@ -26,6 +26,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}
friend bool operator==(const A& x, const A& y)

View File

@@ -29,6 +29,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}
int get() const {return data_;}
@@ -50,6 +52,8 @@ class B
int data_;
public:
B(int d=1) : data_(d) {}
B(const B&) = default;
B& operator=(const B&) = default;
~B() {data_ = -1;}
int get() const {return data_;}

View File

@@ -27,6 +27,8 @@ class A
int data_;
public:
A() : data_(1) {}
A(const A&) = default;
A& operator=(const A&) = default;
~A() {data_ = -1;}
friend bool operator==(const A& x, const A& y)

View File

@@ -29,6 +29,9 @@ struct goroutine
rh = nullptr;
}
goroutine() = default;
goroutine(const goroutine&) = default;
goroutine& operator=(const goroutine&) = default;
~goroutine() {}
static void run_one()

View File

@@ -22,6 +22,7 @@ struct TrackLifetime {
TrackLifetime(LifetimeInformation& info) : info_(&info) {
info_->address_constructed = this;
}
TrackLifetime(TrackLifetime const&) = default;
~TrackLifetime() {
info_->address_destroyed = this;
}
@@ -43,6 +44,7 @@ struct alignas(std::max_align_t) TrackLifetimeMaxAligned {
TrackLifetimeMaxAligned(LifetimeInformation& info) : info_(&info) {
info_->address_constructed = this;
}
TrackLifetimeMaxAligned(TrackLifetimeMaxAligned const&) = default;
~TrackLifetimeMaxAligned() {
info_->address_destroyed = this;
}

View File

@@ -28,6 +28,8 @@ class A
int data_;
public:
explicit A(int data) : data_(data) {}
A(const A&) = default;
A& operator=(const A&) = default;
virtual ~A() TEST_NOEXCEPT {}
friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}

View File

@@ -29,6 +29,9 @@ struct ZeroOnDestroy : std::ranges::view_base {
constexpr ForwardIter end() { return ForwardIter(buff + 8); }
constexpr ForwardIter end() const { return ForwardIter(); }
ZeroOnDestroy() = default;
ZeroOnDestroy(const ZeroOnDestroy&) = default;
ZeroOnDestroy& operator=(const ZeroOnDestroy&) = default;
~ZeroOnDestroy() {
std::memset(buff, 0, sizeof(buff));
}

View File

@@ -44,6 +44,8 @@ struct alloc_first
allocator_constructed = true;
}
alloc_first(const alloc_first&) = default;
alloc_first& operator=(const alloc_first&) = default;
~alloc_first() {data_ = -1;}
friend bool operator==(const alloc_first& x, const alloc_first& y)

View File

@@ -44,6 +44,8 @@ struct alloc_last
allocator_constructed = true;
}
alloc_last(const alloc_last&) = default;
alloc_last& operator=(const alloc_last&) = default;
~alloc_last() {data_ = -1;}
friend bool operator==(const alloc_last& x, const alloc_last& y)

View File

@@ -26,6 +26,8 @@
struct B {
int id_;
explicit B(int i = 0) : id_(i) {}
B(const B&) = default;
B& operator=(const B&) = default;
virtual ~B() {}
};

View File

@@ -36,7 +36,8 @@ struct B
int id_;
explicit B(int i) : id_(i) {}
B(const B&) = default;
B& operator=(const B&) = default;
virtual ~B() {}
};

View File

@@ -20,6 +20,8 @@ public:
typedef bool result_type;
unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
unary_counting_predicate(const unary_counting_predicate&) = default;
unary_counting_predicate& operator=(const unary_counting_predicate&) = default;
~unary_counting_predicate() {}
bool operator () (const Arg &a) const { ++count_; return p_(a); }

View File

@@ -165,6 +165,8 @@ class CDeleter {
public:
TEST_CONSTEXPR_CXX23 CDeleter() : state_(0) {}
TEST_CONSTEXPR_CXX23 explicit CDeleter(int s) : state_(s) {}
TEST_CONSTEXPR_CXX23 CDeleter(const CDeleter&) = default;
TEST_CONSTEXPR_CXX23 CDeleter& operator=(const CDeleter&) = default;
TEST_CONSTEXPR_CXX23 ~CDeleter() {
assert(state_ >= 0);
state_ = -1;
@@ -188,7 +190,8 @@ public:
TEST_CONSTEXPR_CXX23 explicit CDeleter(int s) : state_(s) {}
template <class U>
TEST_CONSTEXPR_CXX23 CDeleter(const CDeleter<U>& d) : state_(d.state()) {}
TEST_CONSTEXPR_CXX23 CDeleter(const CDeleter&) = default;
TEST_CONSTEXPR_CXX23 CDeleter& operator=(const CDeleter&) = default;
TEST_CONSTEXPR_CXX23 ~CDeleter() {
assert(state_ >= 0);
state_ = -1;

View File

@@ -43,6 +43,8 @@ public:
#if TEST_STD_VER >= 11
nasty_vector(std::initializer_list<value_type> il) : v_(il) {}
#endif
nasty_vector(const nasty_vector&) = default;
nasty_vector& operator=(const nasty_vector&) = default;
~nasty_vector() {}
template <class InputIterator>
@@ -174,7 +176,8 @@ public:
#if TEST_STD_VER >= 11
nasty_list(std::initializer_list<value_type> il) : l_(il) {}
#endif
nasty_list(const nasty_list&) = default;
nasty_list& operator=(const nasty_list&) = default;
~nasty_list() {}
#if TEST_STD_VER >= 11

View File

@@ -25,6 +25,8 @@ _warningFlags = [
"-Wno-aligned-allocation-unavailable",
"-Wno-atomic-alignment",
"-Wno-reserved-module-identifier",
'-Wdeprecated-copy',
'-Wdeprecated-copy-dtor',
# GCC warns about places where we might want to add sized allocation/deallocation
# functions, but we know better what we're doing/testing in the test suite.
"-Wno-sized-deallocation",

View File

@@ -18,6 +18,8 @@
struct exception {
exception() : x(0) { }
exception(const exception&) = default;
exception& operator=(const exception&) = default;
virtual ~exception() { }
int x;
};