summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-12-14 22:48:38 +0000
committerEric Fiselier <eric@efcs.ca>2016-12-14 22:48:38 +0000
commit5cac7755ab6bb6956ec1bea5ebe108e7341fdbdd (patch)
tree803ced336cc94efb4854401c798dbedb12ee2e67 /libcxx/test/support
parent286adee501ef95240fb926d170dd287887976d01 (diff)
downloadbcm5719-llvm-5cac7755ab6bb6956ec1bea5ebe108e7341fdbdd.tar.gz
bcm5719-llvm-5cac7755ab6bb6956ec1bea5ebe108e7341fdbdd.zip
Fix PR31378 - std::list::remove should not require a default constructible allocator.
In list::remove we collect the nodes we're removing in a seperate list instance. However we construct this list using the default constructor which default constructs the allocator. However allocators are not required to be default constructible. This patch fixes the construction of the second list. llvm-svn: 289735
Diffstat (limited to 'libcxx/test/support')
-rw-r--r--libcxx/test/support/controlled_allocators.hpp4
-rw-r--r--libcxx/test/support/min_allocator.h38
2 files changed, 42 insertions, 0 deletions
diff --git a/libcxx/test/support/controlled_allocators.hpp b/libcxx/test/support/controlled_allocators.hpp
index 4d5e74a3579..878b7455a5a 100644
--- a/libcxx/test/support/controlled_allocators.hpp
+++ b/libcxx/test/support/controlled_allocators.hpp
@@ -20,6 +20,10 @@
#include "test_macros.h"
#include "type_id.h"
+#if TEST_STD_VER < 11
+#error This header requires C++11 or greater
+#endif
+
struct AllocController;
// 'AllocController' is a concrete type that instruments and controls the
// behavior of of test allocators.
diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h
index 8e0afab4763..d518e4a6d77 100644
--- a/libcxx/test/support/min_allocator.h
+++ b/libcxx/test/support/min_allocator.h
@@ -42,6 +42,44 @@ public:
friend bool operator!=(bare_allocator x, bare_allocator y) {return !(x == y);}
};
+
+template <class T>
+class no_default_allocator
+{
+#if TEST_STD_VER >= 11
+ no_default_allocator() = delete;
+#else
+ no_default_allocator();
+#endif
+ struct construct_tag {};
+ explicit no_default_allocator(construct_tag) {}
+
+public:
+ static no_default_allocator create() {
+ construct_tag tag;
+ return no_default_allocator(tag);
+ }
+
+public:
+ typedef T value_type;
+
+ template <class U>
+ no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {}
+
+ T* allocate(std::size_t n)
+ {
+ return static_cast<T*>(::operator new(n*sizeof(T)));
+ }
+
+ void deallocate(T* p, std::size_t)
+ {
+ return ::operator delete(static_cast<void*>(p));
+ }
+
+ friend bool operator==(no_default_allocator, no_default_allocator) {return true;}
+ friend bool operator!=(no_default_allocator x, no_default_allocator y) {return !(x == y);}
+};
+
struct malloc_allocator_base {
static size_t alloc_count;
static size_t dealloc_count;
OpenPOWER on IntegriCloud