From: Roger Ferrer Ibanez Date: Wed, 2 Nov 2016 08:14:57 +0000 (+0000) Subject: Protect tests for new/delete under libcpp-no-exceptions X-Git-Tag: llvmorg-4.0.0-rc1~5658 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c6562398e4a49205533c45238e68ba89d1d2c48;p=platform%2Fupstream%2Fllvm.git 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 llvm-svn: 285791 --- diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp index 55a3200..dd4ff46 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp @@ -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 #include +#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); diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp index 9531b1c..910c94a 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp @@ -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 #include +#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::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); diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp index 892842a..26f7bc3 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp @@ -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 #include +#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); diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp index c2f5830..757e8ae 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp @@ -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 #include +#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::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);