Protect tests for new/delete under libcpp-no-exceptions
authorRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Wed, 2 Nov 2016 08:14:57 +0000 (08:14 +0000)
committerRoger Ferrer Ibanez <roger.ferreribanez@arm.com>
Wed, 2 Nov 2016 08:14:57 +0000 (08:14 +0000)
Skip the tests that expect an exception be thrown and protect unreachable catch blocks.

Differential Revision: https://reviews.llvm.org/D26197

llvm-svn: 285791

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp

index 55a3200..dd4ff46 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new[]
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include <cassert>
 #include <limits>
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -36,6 +37,7 @@ struct A
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
     std::set_new_handler(new_handler);
     try
     {
@@ -51,6 +53,7 @@ int main()
     {
         assert(false);
     }
+#endif
     A* ap = new A[3];
     assert(ap);
     assert(A_constructed == 3);
index 9531b1c..910c94a 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new [] (nothrow)
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include <cassert>
 #include <limits>
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@ struct A
 int main()
 {
     std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
+#endif TEST_HAS_NO_EXCEPTIONS
     {
         void*volatile vp = operator new [] (std::numeric_limits<std::size_t>::max(), std::nothrow);
         assert(new_handler_called == 1);
         assert(vp == 0);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     catch (...)
     {
         assert(false);
     }
+#endif
     A* ap = new(std::nothrow) A[3];
     assert(ap);
     assert(A_constructed == 3);
index 892842a..26f7bc3 100644 (file)
@@ -7,8 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
-
 // test operator new
 
 // asan and msan will not call the new handler.
@@ -19,6 +17,8 @@
 #include <cassert>
 #include <limits>
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,6 +37,7 @@ struct A
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
     std::set_new_handler(new_handler);
     try
     {
@@ -52,6 +53,7 @@ int main()
     {
         assert(false);
     }
+#endif
     A* ap = new A;
     assert(ap);
     assert(A_constructed);
index c2f5830..757e8ae 100644 (file)
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new (nothrow)
 
 // asan and msan will not call the new handler.
@@ -18,6 +17,8 @@
 #include <cassert>
 #include <limits>
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@ struct A
 int main()
 {
     std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
+#endif
     {
         void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::nothrow);
         assert(new_handler_called == 1);
         assert(vp == 0);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     catch (...)
     {
         assert(false);
     }
+#endif
     A* ap = new(std::nothrow) A;
     assert(ap);
     assert(A_constructed);