summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/test/containers/stack_allocator.h7
-rw-r--r--libcxx/test/containers/test_allocator.h7
-rw-r--r--libcxx/test/re/test_allocator.h7
-rw-r--r--libcxx/test/strings/basic.string/test_allocator.h7
-rw-r--r--libcxx/test/thread/futures/test_allocator.h7
-rw-r--r--libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h7
-rw-r--r--libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h7
7 files changed, 42 insertions, 7 deletions
diff --git a/libcxx/test/containers/stack_allocator.h b/libcxx/test/containers/stack_allocator.h
index 30f58718eb2..e6af473816a 100644
--- a/libcxx/test/containers/stack_allocator.h
+++ b/libcxx/test/containers/stack_allocator.h
@@ -29,8 +29,13 @@ private:
public:
pointer allocate(size_type n, const void* = 0)
{
- if (n > N - (ptr_ - buf_) / sizeof(value_type))
+ if (n > N - (ptr_ - buf_) / sizeof(value_type)) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
pointer r = (T*)ptr_;
ptr_ += n * sizeof(T);
return r;
diff --git a/libcxx/test/containers/test_allocator.h b/libcxx/test/containers/test_allocator.h
index c5da7e6390d..eed33a0e3ea 100644
--- a/libcxx/test/containers/test_allocator.h
+++ b/libcxx/test/containers/test_allocator.h
@@ -48,8 +48,13 @@ public:
const_pointer address(const_reference x) const {return &x;}
pointer allocate(size_type n, const void* = 0)
{
- if (count >= throw_after)
+ if (count >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
++count;
return (pointer)std::malloc(n * sizeof(T));
}
diff --git a/libcxx/test/re/test_allocator.h b/libcxx/test/re/test_allocator.h
index c5da7e6390d..eed33a0e3ea 100644
--- a/libcxx/test/re/test_allocator.h
+++ b/libcxx/test/re/test_allocator.h
@@ -48,8 +48,13 @@ public:
const_pointer address(const_reference x) const {return &x;}
pointer allocate(size_type n, const void* = 0)
{
- if (count >= throw_after)
+ if (count >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
++count;
return (pointer)std::malloc(n * sizeof(T));
}
diff --git a/libcxx/test/strings/basic.string/test_allocator.h b/libcxx/test/strings/basic.string/test_allocator.h
index 001ca98bd67..89852159d3c 100644
--- a/libcxx/test/strings/basic.string/test_allocator.h
+++ b/libcxx/test/strings/basic.string/test_allocator.h
@@ -48,8 +48,13 @@ public:
const_pointer address(const_reference x) const {return &x;}
pointer allocate(size_type n, const void* = 0)
{
- if (count >= throw_after)
+ if (count >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
++count;
return (pointer)std::malloc(n * sizeof(T));
}
diff --git a/libcxx/test/thread/futures/test_allocator.h b/libcxx/test/thread/futures/test_allocator.h
index 7644bc7c968..e04d4320619 100644
--- a/libcxx/test/thread/futures/test_allocator.h
+++ b/libcxx/test/thread/futures/test_allocator.h
@@ -48,8 +48,13 @@ public:
const_pointer address(const_reference x) const {return &x;}
pointer allocate(size_type n, const void* = 0)
{
- if (count >= throw_after)
+ if (count >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
++count;
return (pointer)std::malloc(n * sizeof(T));
}
diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h
index c5da7e6390d..eed33a0e3ea 100644
--- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h
+++ b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h
@@ -48,8 +48,13 @@ public:
const_pointer address(const_reference x) const {return &x;}
pointer allocate(size_type n, const void* = 0)
{
- if (count >= throw_after)
+ if (count >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
++count;
return (pointer)std::malloc(n * sizeof(T));
}
diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h
index 795f6e1f77e..d9b72bce49e 100644
--- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h
+++ b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h
@@ -54,8 +54,13 @@ public:
pointer allocate(size_type n, const void* = 0)
{
assert(data_ >= 0);
- if (time_to_throw >= throw_after)
+ if (time_to_throw >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
++time_to_throw;
++alloc_count;
return (pointer)std::malloc(n * sizeof(T));
OpenPOWER on IntegriCloud