Skip the tests that expect an exception be thrown and protect unreachable catch blocks.
Differential Revision: https://reviews.llvm.org/D26197
llvm-svn: 285791
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// test operator new[]
// NOTE: asan and msan will not call the new handler.
// UNSUPPORTED: sanitizer-new-delete
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_handler_called = 0;
void new_handler()
int main()
{
+#ifndef TEST_HAS_NO_EXCEPTIONS
std::set_new_handler(new_handler);
try
{
{
assert(false);
}
+#endif
A* ap = new A[3];
assert(ap);
assert(A_constructed == 3);
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// test operator new [] (nothrow)
// NOTE: asan and msan will not call the new handler.
// UNSUPPORTED: sanitizer-new-delete
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_handler_called = 0;
void new_handler()
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);
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
-
// test operator new
// asan and msan will not call the new handler.
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_handler_called = 0;
void new_handler()
int main()
{
+#ifndef TEST_HAS_NO_EXCEPTIONS
std::set_new_handler(new_handler);
try
{
{
assert(false);
}
+#endif
A* ap = new A;
assert(ap);
assert(A_constructed);
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// test operator new (nothrow)
// asan and msan will not call the new handler.
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_handler_called = 0;
void new_handler()
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);