[libcxx] r285791 - Protect tests for new/delete under libcpp-no-exceptions

Roger Ferrer Ibanez via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 2 01:14:58 PDT 2016


Author: rogfer01
Date: Wed Nov  2 03:14:57 2016
New Revision: 285791

URL: http://llvm.org/viewvc/llvm-project?rev=285791&view=rev
Log:
Protect tests for new/delete under libcpp-no-exceptions

Skip the tests that expect an exception be thrown and protect unreachable catch blocks.

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


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

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp?rev=285791&r1=285790&r2=285791&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp Wed Nov  2 03:14:57 2016
@@ -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);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp?rev=285791&r1=285790&r2=285791&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp Wed Nov  2 03:14:57 2016
@@ -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);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp?rev=285791&r1=285790&r2=285791&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp Wed Nov  2 03:14:57 2016
@@ -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);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp?rev=285791&r1=285790&r2=285791&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp Wed Nov  2 03:14:57 2016
@@ -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);




More information about the cfe-commits mailing list