From 0a20660c8fcb5bb8469e323585eeaecacea67c44 Mon Sep 17 00:00:00 2001 From: zoecarver Date: Mon, 23 Nov 2020 14:21:50 -0800 Subject: [PATCH] [libcxx] Resolve LWG 2724 protected -> private. Fixes LWG issue 2724: "The protected virtual member functions of memory_resource should be private." Differential Revision: https://reviews.llvm.org/D66615 --- libcxx/include/experimental/memory_resource | 5 ++--- .../{protected_members.fail.cpp => private_members.fail.cpp} | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) rename libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/{protected_members.fail.cpp => private_members.fail.cpp} (73%) diff --git a/libcxx/include/experimental/memory_resource b/libcxx/include/experimental/memory_resource index f999fb9..816d21f 100644 --- a/libcxx/include/experimental/memory_resource +++ b/libcxx/include/experimental/memory_resource @@ -116,7 +116,7 @@ public: { return do_is_equal(__other); } // 8.5.3, memory.resource.priv -protected: +private: virtual void* do_allocate(size_t, size_t) = 0; virtual void do_deallocate(void*, size_t, size_t) = 0; virtual bool do_is_equal(memory_resource const &) const _NOEXCEPT = 0; @@ -381,7 +381,7 @@ public: { return __alloc_; } // 8.7.3, memory.resource.adaptor.mem -protected: +private: virtual void * do_allocate(size_t __bytes, size_t) { if (__bytes > __max_size()) { @@ -407,7 +407,6 @@ protected: return __p ? __alloc_ == __p->__alloc_ : false; } -private: _LIBCPP_INLINE_VISIBILITY size_t __max_size() const _NOEXCEPT { return numeric_limits::max() - _MaxAlign; diff --git a/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp b/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/private_members.fail.cpp similarity index 73% rename from libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp rename to libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/private_members.fail.cpp index 85c4ce4..a0c84b0 100644 --- a/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/protected_members.fail.cpp +++ b/libcxx/test/std/experimental/memory/memory.resource/memory.resource.priv/private_members.fail.cpp @@ -10,9 +10,9 @@ // -// memory_resource::do_allocate(size_t, size_t); /* protected */ -// memory_resource::do_deallocate(void*, size_t, size_t); /* protected */ -// memory_resource::do_is_equal(memory_resource const&); /* protected */ +// memory_resource::do_allocate(size_t, size_t); /* private */ +// memory_resource::do_deallocate(void*, size_t, size_t); /* private */ +// memory_resource::do_is_equal(memory_resource const&); /* private */ #include @@ -20,9 +20,9 @@ namespace ex = std::experimental::pmr; int main(int, char**) { ex::memory_resource *m = ex::new_delete_resource(); - m->do_allocate(0, 0); // expected-error{{'do_allocate' is a protected member}} - m->do_deallocate(nullptr, 0, 0); // expected-error{{'do_deallocate' is a protected member}} - m->do_is_equal(*m); // expected-error{{'do_is_equal' is a protected member}} + m->do_allocate(0, 0); // expected-error{{'do_allocate' is a private member}} + m->do_deallocate(nullptr, 0, 0); // expected-error{{'do_deallocate' is a private member}} + m->do_is_equal(*m); // expected-error{{'do_is_equal' is a private member}} return 0; } -- 2.7.4