This is a start at making the libc++ test suite friendlier to the -fnoexceptions...
authorHoward Hinnant <hhinnant@apple.com>
Sat, 23 Mar 2013 17:27:16 +0000 (17:27 +0000)
committerHoward Hinnant <hhinnant@apple.com>
Sat, 23 Mar 2013 17:27:16 +0000 (17:27 +0000)
llvm-svn: 177824

libcxx/test/containers/stack_allocator.h
libcxx/test/containers/test_allocator.h
libcxx/test/re/test_allocator.h
libcxx/test/strings/basic.string/test_allocator.h
libcxx/test/thread/futures/test_allocator.h
libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h
libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_allocator.h

index 30f5871..e6af473 100644 (file)
@@ -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;
index c5da7e6..eed33a0 100644 (file)
@@ -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));
         }
index c5da7e6..eed33a0 100644 (file)
@@ -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));
         }
index 001ca98..8985215 100644 (file)
@@ -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));
         }
index 7644bc7..e04d432 100644 (file)
@@ -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));
         }
index c5da7e6..eed33a0 100644 (file)
@@ -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));
         }
index 795f6e1..d9b72bc 100644 (file)
@@ -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));