summaryrefslogtreecommitdiff
path: root/test/std/language.support
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:58 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:58 +0000
commit53a420fba21cf1644972b34dcd811a43cdb8368d (patch)
tree66a19f6f8b65215772549a51d688492ab8addc0d /test/std/language.support
parentb50f1549701eb950921e5d6f2e55ba1a1dadbb43 (diff)
Notes
Diffstat (limited to 'test/std/language.support')
-rw-r--r--test/std/language.support/support.dynamic/align_val_t.pass.cpp34
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp89
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp80
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp82
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp83
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp85
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp5
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp7
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp14
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp13
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp8
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp8
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp6
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp8
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp90
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp6
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp80
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp82
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp84
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp85
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp7
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp13
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp6
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp8
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp8
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp14
-rw-r--r--test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp15
-rw-r--r--test/std/language.support/support.exception/except.nested/assign.pass.cpp5
-rw-r--r--test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp5
-rw-r--r--test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp5
-rw-r--r--test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp6
-rw-r--r--test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp2
-rw-r--r--test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp2
-rw-r--r--test/std/language.support/support.exception/propagation/current_exception.pass.cpp2
-rw-r--r--test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp2
-rw-r--r--test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp2
-rw-r--r--test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp2
-rw-r--r--test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp2
-rw-r--r--test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp15
-rw-r--r--test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp6
-rw-r--r--test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp15
-rw-r--r--test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp2
-rw-r--r--test/std/language.support/support.runtime/cstdlib.pass.cpp2
-rw-r--r--test/std/language.support/support.types/nullptr_t.pass.cpp25
44 files changed, 1026 insertions, 94 deletions
diff --git a/test/std/language.support/support.dynamic/align_val_t.pass.cpp b/test/std/language.support/support.dynamic/align_val_t.pass.cpp
new file mode 100644
index 000000000000..0a19de919f7f
--- /dev/null
+++ b/test/std/language.support/support.dynamic/align_val_t.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// enum class align_val_t : size_t {}
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include <new>
+
+#include "test_macros.h"
+
+int main() {
+ {
+ static_assert(std::is_enum<std::align_val_t>::value, "");
+ static_assert(std::is_same<std::underlying_type<std::align_val_t>::type, std::size_t>::value, "");
+ static_assert(!std::is_constructible<std::align_val_t, std::size_t>::value, "");
+ static_assert(!std::is_constructible<std::size_t, std::align_val_t>::value, "");
+ }
+ {
+ constexpr auto a = std::align_val_t(0);
+ constexpr auto b = std::align_val_t(32);
+ constexpr auto c = std::align_val_t(-1);
+ static_assert(a != b, "");
+ static_assert(a == std::align_val_t(0), "");
+ static_assert(b == std::align_val_t(32), "");
+ static_assert(static_cast<std::size_t>(c) == (std::size_t)-1, "");
+ }
+} \ No newline at end of file
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
new file mode 100644
index 000000000000..c88e5b06e675
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test aligned operator delete replacement.
+
+// UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11, c++14
+
+// Older Clang versions do not support this
+// XFAIL: clang-3, apple-clang
+
+// None of the current GCC compilers support this.
+// XFAIL: gcc
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int aligned_delete_called = 0;
+
+void reset() {
+ unsized_delete_called = 0;
+ unsized_delete_nothrow_called = 0;
+ aligned_delete_called = 0;
+}
+
+void operator delete(void* p) TEST_NOEXCEPT
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete [] (void* p, std::align_val_t) TEST_NOEXCEPT
+{
+ ++aligned_delete_called;
+ std::free(p);
+}
+
+struct alignas(OverAligned) A {};
+struct alignas(std::max_align_t) B {};
+
+B* volatile b; // Escape the memory
+A* volatile a;
+
+int main()
+{
+ reset();
+ {
+ b = new B[2];
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == aligned_delete_called);
+
+ delete [] b;
+ assert(1 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == aligned_delete_called);
+ }
+ reset();
+ {
+ a = new A[2];
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == aligned_delete_called);
+
+ delete [] a;
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(1 == aligned_delete_called);
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
new file mode 100644
index 000000000000..55c26fa5c4a7
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+// FIXME change this to XFAIL.
+// UNSUPPORTED: no-aligned-allocation
+
+// test operator new
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <cstdint>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct alignas(OverAligned) A
+{
+ A() { ++A_constructed;}
+ ~A() { --A_constructed;}
+};
+
+void test_throw_max_size() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ std::set_new_handler(new_handler);
+ try
+ {
+ void* vp = operator new[] (std::numeric_limits<std::size_t>::max(),
+ static_cast<std::align_val_t>(32));
+ ((void)vp);
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(new_handler_called == 1);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+#endif
+}
+
+int main()
+{
+ {
+ A* ap = new A[2];
+ assert(ap);
+ assert(reinterpret_cast<std::uintptr_t>(ap) % OverAligned == 0);
+ assert(A_constructed == 2);
+ delete [] ap;
+ assert(A_constructed == 0);
+ }
+ {
+ test_throw_max_size();
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
new file mode 100644
index 000000000000..28da3093f398
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+// FIXME turn this into an XFAIL
+// UNSUPPORTED: no-aligned-allocation
+
+// test operator new (nothrow)
+
+#include <new>
+#include <cstddef>
+#include <cstdint>
+#include <cassert>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct alignas(OverAligned) A
+{
+ A() { ++A_constructed; }
+ ~A() { --A_constructed; }
+};
+
+void test_max_alloc() {
+ std::set_new_handler(new_handler);
+ auto do_test = []() {
+ void* vp = operator new [](std::numeric_limits<std::size_t>::max(),
+ std::align_val_t(OverAligned),
+ std::nothrow);
+ assert(new_handler_called == 1);
+ assert(vp == 0);
+ };
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ try
+ {
+ do_test();
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+#else
+ do_test();
+#endif
+}
+
+int main()
+{
+ {
+ A* ap = new(std::nothrow) A[3];
+ assert(ap);
+ assert(reinterpret_cast<std::uintptr_t>(ap) % OverAligned == 0);
+ assert(A_constructed == 3);
+ delete [] ap;
+ assert(!A_constructed);
+ }
+ {
+ test_max_alloc();
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
new file mode 100644
index 000000000000..03e490e8ed85
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: sanitizer-new-delete
+
+// XFAIL: no-aligned-allocation
+
+// test operator new nothrow by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int A_constructed = 0;
+
+struct alignas(OverAligned) A
+{
+ A() {++A_constructed;}
+ ~A() {--A_constructed;}
+};
+
+int B_constructed = 0;
+
+struct B {
+ std::max_align_t member;
+ B() { ++B_constructed; }
+ ~B() { --B_constructed; }
+};
+
+int new_called = 0;
+alignas(OverAligned) char Buff[OverAligned * 3];
+
+void* operator new[](std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
+{
+ assert(!new_called);
+ assert(s <= sizeof(Buff));
+ assert(static_cast<std::size_t>(a) == OverAligned);
+ ++new_called;
+ return Buff;
+}
+
+void operator delete[](void* p, std::align_val_t a) TEST_NOEXCEPT
+{
+ assert(p == Buff);
+ assert(static_cast<std::size_t>(a) == OverAligned);
+ assert(new_called);
+ --new_called;
+}
+
+int main()
+{
+ {
+ A* ap = new (std::nothrow) A[2];
+ assert(ap);
+ assert(A_constructed == 2);
+ assert(new_called);
+ delete [] ap;
+ assert(A_constructed == 0);
+ assert(!new_called);
+ }
+ {
+ B* bp = new (std::nothrow) B[2];
+ assert(bp);
+ assert(B_constructed == 2);
+ assert(!new_called);
+ delete [] bp;
+ assert(!new_called);
+ assert(!B_constructed);
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
new file mode 100644
index 000000000000..131deb340d2f
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_replace.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: sanitizer-new-delete
+
+// XFAIL: no-aligned-allocation
+
+// test operator new replacement
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cstdint>
+#include <cassert>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int A_constructed = 0;
+
+struct alignas(OverAligned) A {
+ A() { ++A_constructed;}
+ ~A() { --A_constructed;}
+};
+
+
+int B_constructed = 0;
+
+struct alignas(std::max_align_t) B
+{
+ std::max_align_t member;
+ B() { ++B_constructed;}
+ ~B() { --B_constructed;}
+};
+
+int new_called = 0;
+
+alignas(OverAligned) char DummyData[OverAligned * 4];
+
+void* operator new[](std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
+{
+ assert(new_called == 0); // We already allocated
+ assert(s <= sizeof(DummyData));
+ assert(static_cast<std::size_t>(a) == OverAligned);
+ ++new_called;
+ return DummyData;
+}
+
+void operator delete[](void* p, std::align_val_t) TEST_NOEXCEPT
+{
+ assert(new_called == 1);
+ --new_called;
+ assert(p == DummyData);
+}
+
+
+int main()
+{
+ {
+ A* ap = new A[3];
+ assert(ap);
+ assert(A_constructed == 3);
+ assert(new_called);
+ delete [] ap;
+ assert(!A_constructed);
+ assert(!new_called);
+ }
+ {
+ B* bp = new B[3];
+ assert(bp);
+ assert(B_constructed == 3);
+ assert(!new_called);
+ delete [] bp;
+ assert(!new_called);
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
index 55a3200a13b7..dd4ff46bceb9 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
+++ b/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 <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);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
index 9531b1c37480..2f51b1990436 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
+++ b/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 <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*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);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
index 5887bb0bdf30..53e26c99f92e 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
@@ -11,19 +11,17 @@
// UNSUPPORTED: sanitizer-new-delete
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
-
#include <new>
#include <cstddef>
#include <cstdlib>
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
@@ -31,7 +29,7 @@ void* operator new(std::size_t s) throw(std::bad_alloc)
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
@@ -45,9 +43,11 @@ struct A
~A() {--A_constructed;}
};
+A* volatile ap;
+
int main()
{
- A* ap = new (std::nothrow) A[3];
+ ap = new (std::nothrow) A[3];
assert(ap);
assert(A_constructed == 3);
assert(new_called);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
index 1e78ea8fe267..b0820b14f410 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
@@ -11,9 +11,6 @@
// UNSUPPORTED: sanitizer-new-delete
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
#include <new>
#include <cstddef>
@@ -21,9 +18,11 @@
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
volatile int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
@@ -31,7 +30,7 @@ void* operator new(std::size_t s) throw(std::bad_alloc)
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
@@ -45,9 +44,11 @@ struct A
~A() {--A_constructed;}
};
+A* volatile ap;
+
int main()
{
- A* ap = new A[3];
+ ap = new A[3];
assert(ap);
assert(A_constructed == 3);
assert(new_called == 1);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
index 0f7840ca9ef8..3e41b24d292f 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp
@@ -20,23 +20,25 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete[](void* p, std::size_t) throw()
+void operator delete[](void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
index 0e2cc6d8da4e..fb715805083f 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp
@@ -25,23 +25,25 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete[](void* p, std::size_t) throw()
+void operator delete[](void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
index 6d24aec35ef8..ff55ec74e3cd 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
@@ -18,16 +18,18 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int delete_called = 0;
int delete_nothrow_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++delete_nothrow_called;
std::free(p);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp
index 7dd510b4dac8..5b93540eac57 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.cpp
@@ -33,23 +33,25 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete[](void* p) throw()
+void operator delete[](void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete[](void* p, const std::nothrow_t&) throw()
+void operator delete[](void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete[](void* p, std::size_t) throw()
+void operator delete[](void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
new file mode 100644
index 000000000000..a5d4df34a85d
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test aligned operator delete replacement.
+
+// UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11, c++14
+
+// Older Clang versions do not support this
+// XFAIL: clang-3, apple-clang
+
+// None of the current GCC compilers support this.
+// XFAIL: gcc
+
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int unsized_delete_called = 0;
+int unsized_delete_nothrow_called = 0;
+int aligned_delete_called = 0;
+
+void reset() {
+ unsized_delete_called = 0;
+ unsized_delete_nothrow_called = 0;
+ aligned_delete_called = 0;
+}
+
+void operator delete(void* p) TEST_NOEXCEPT
+{
+ ++unsized_delete_called;
+ std::free(p);
+}
+
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
+{
+ ++unsized_delete_nothrow_called;
+ std::free(p);
+}
+
+void operator delete(void* p, std::align_val_t) TEST_NOEXCEPT
+{
+ ++aligned_delete_called;
+ std::free(p);
+}
+
+struct alignas(OverAligned) A {};
+struct alignas(std::max_align_t) B {};
+
+B* volatile bp;
+A* volatile ap;
+
+int main()
+{
+ reset();
+ {
+ bp = new B;
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == aligned_delete_called);
+
+ delete bp;
+ assert(1 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == aligned_delete_called);
+ }
+ reset();
+ {
+ ap = new A;
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(0 == aligned_delete_called);
+
+ delete ap;
+ assert(0 == unsized_delete_called);
+ assert(0 == unsized_delete_nothrow_called);
+ assert(1 == aligned_delete_called);
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
index 892842a1b9f4..26f7bc392c79 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
+++ b/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 <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);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
new file mode 100644
index 000000000000..fefae51dac93
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+// FIXME turn this into an XFAIL
+// UNSUPPORTED: no-aligned-allocation
+
+// test operator new
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <cstdint>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct alignas(OverAligned) A
+{
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+void test_throw_max_size() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ std::set_new_handler(new_handler);
+ try
+ {
+ void* vp = operator new (std::numeric_limits<std::size_t>::max(),
+ static_cast<std::align_val_t>(32));
+ ((void)vp);
+ assert(false);
+ }
+ catch (std::bad_alloc&)
+ {
+ assert(new_handler_called == 1);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+#endif
+}
+
+int main()
+{
+ {
+ A* ap = new A;
+ assert(ap);
+ assert(reinterpret_cast<std::uintptr_t>(ap) % OverAligned == 0);
+ assert(A_constructed);
+ delete ap;
+ assert(!A_constructed);
+ }
+ {
+ test_throw_max_size();
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
new file mode 100644
index 000000000000..ca8503e8854d
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// asan and msan will not call the new handler.
+// UNSUPPORTED: sanitizer-new-delete
+
+// FIXME turn this into an XFAIL
+// UNSUPPORTED: no-aligned-allocation
+
+// test operator new (nothrow)
+
+#include <new>
+#include <cstddef>
+#include <cstdint>
+#include <cassert>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+ ++new_handler_called;
+ std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct alignas(OverAligned) A
+{
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+void test_max_alloc() {
+ std::set_new_handler(new_handler);
+ auto do_test = []() {
+ void* vp = operator new (std::numeric_limits<std::size_t>::max(),
+ std::align_val_t(OverAligned),
+ std::nothrow);
+ assert(new_handler_called == 1);
+ assert(vp == 0);
+ };
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ try
+ {
+ do_test();
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+#else
+ do_test();
+#endif
+}
+
+int main()
+{
+ {
+ A* ap = new(std::nothrow) A;
+ assert(ap);
+ assert(reinterpret_cast<std::uintptr_t>(ap) % OverAligned == 0);
+ assert(A_constructed);
+ delete ap;
+ assert(!A_constructed);
+ }
+ {
+ test_max_alloc();
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
new file mode 100644
index 000000000000..9f64c9730166
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: sanitizer-new-delete
+
+// XFAIL: no-aligned-allocation
+
+// test operator new nothrow by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+bool A_constructed = false;
+
+struct alignas(OverAligned) A
+{
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+bool B_constructed = false;
+
+struct B {
+ std::max_align_t member;
+ B() { B_constructed = true; }
+ ~B() { B_constructed = false; }
+};
+
+int new_called = 0;
+alignas(OverAligned) char Buff[OverAligned * 2];
+
+void* operator new(std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
+{
+ assert(!new_called);
+ assert(s <= sizeof(Buff));
+ assert(static_cast<std::size_t>(a) == OverAligned);
+ ++new_called;
+ return Buff;
+}
+
+void operator delete(void* p, std::align_val_t a) TEST_NOEXCEPT
+{
+ assert(p == Buff);
+ assert(static_cast<std::size_t>(a) == OverAligned);
+ assert(new_called);
+ --new_called;
+}
+
+
+int main()
+{
+ {
+ A* ap = new (std::nothrow) A;
+ assert(ap);
+ assert(A_constructed);
+ assert(new_called);
+ delete ap;
+ assert(!A_constructed);
+ assert(!new_called);
+ }
+ {
+ B* bp = new (std::nothrow) B;
+ assert(bp);
+ assert(B_constructed);
+ assert(!new_called);
+ delete bp;
+ assert(!new_called);
+ assert(!B_constructed);
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
new file mode 100644
index 000000000000..df3e4c1560a9
--- /dev/null
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_replace.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: sanitizer-new-delete
+
+// XFAIL: no-aligned-allocation
+
+// test operator new replacement
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cstdint>
+#include <cassert>
+#include <limits>
+
+#include "test_macros.h"
+
+constexpr auto OverAligned = alignof(std::max_align_t) * 2;
+
+bool A_constructed = false;
+
+struct alignas(OverAligned) A {
+ A() {A_constructed = true;}
+ ~A() {A_constructed = false;}
+};
+
+
+bool B_constructed = false;
+
+struct alignas(std::max_align_t) B
+{
+ std::max_align_t member;
+ B() {B_constructed = true;}
+ ~B() {B_constructed = false;}
+};
+
+int new_called = 0;
+
+alignas(OverAligned) char DummyData[OverAligned];
+
+void* operator new(std::size_t s, std::align_val_t a) TEST_THROW_SPEC(std::bad_alloc)
+{
+ assert(new_called == 0); // We already allocated
+ assert(s <= sizeof(DummyData));
+ assert(static_cast<std::size_t>(a) == OverAligned);
+ ++new_called;
+ return DummyData;
+}
+
+void operator delete(void* p, std::align_val_t) TEST_NOEXCEPT
+{
+ assert(new_called == 1);
+ --new_called;
+ assert(p == DummyData);
+}
+
+
+int main()
+{
+ {
+ A* ap = new A;
+ assert(ap);
+ assert(A_constructed);
+ assert(new_called);
+ delete ap;
+ assert(!A_constructed);
+ assert(!new_called);
+ }
+ {
+ B* bp = new B;
+ assert(bp);
+ assert(B_constructed);
+ assert(!new_called);
+ delete bp;
+ assert(!new_called);
+ }
+}
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
index c2f5830495d2..757e8ae18a47 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
+++ b/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 <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);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
index eb8319bac2f7..dbc64bace332 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
@@ -11,18 +11,17 @@
// UNSUPPORTED: sanitizer-new-delete
-// TODO Investigate why UBSAN prevents nothrow new from calling our replacement.
-// XFAIL: ubsan
-
#include <new>
#include <cstddef>
#include <cstdlib>
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
@@ -30,7 +29,7 @@ void* operator new(std::size_t s) throw(std::bad_alloc)
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
@@ -44,9 +43,11 @@ struct A
~A() {A_constructed = false;}
};
+A* volatile ap;
+
int main()
{
- A* ap = new (std::nothrow) A;
+ ap = new (std::nothrow) A;
assert(ap);
assert(A_constructed);
assert(new_called);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
index 6056ed7bb0b3..ad15b49483d0 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
@@ -17,9 +17,11 @@
#include <cassert>
#include <limits>
+#include "test_macros.h"
+
int new_called = 0;
-void* operator new(std::size_t s) throw(std::bad_alloc)
+void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
{
++new_called;
void* ret = std::malloc(s);
@@ -27,7 +29,7 @@ void* operator new(std::size_t s) throw(std::bad_alloc)
return ret;
}
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
--new_called;
std::free(p);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
index e4064e2ab510..7369c362fce2 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
@@ -20,23 +20,25 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete(void* p, std::size_t) throw()
+void operator delete(void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
index 5d9ddd4f0526..6c91f5ceda86 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
@@ -25,23 +25,25 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete(void* p, std::size_t) throw()
+void operator delete(void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp
index f656d1cd712a..cb093f3637ce 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp
@@ -13,33 +13,33 @@
// UNSUPPORTED: sanitizer-new-delete
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
-
#include <new>
#include <cstddef>
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int delete_called = 0;
int delete_nothrow_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++delete_nothrow_called;
std::free(p);
}
+int* volatile x;
+
int main()
{
- int *x = new int(42);
+ x = new int(42);
assert(0 == delete_called);
assert(0 == delete_nothrow_called);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
index 24d33e210f57..1b6de2367e10 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
@@ -14,9 +14,6 @@
// UNSUPPORTED: sanitizer-new-delete
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
// NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation.
// REQUIRES: fsized-deallocation
@@ -36,31 +33,35 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
int unsized_delete_called = 0;
int unsized_delete_nothrow_called = 0;
int sized_delete_called = 0;
-void operator delete(void* p) throw()
+void operator delete(void* p) TEST_NOEXCEPT
{
++unsized_delete_called;
std::free(p);
}
-void operator delete(void* p, const std::nothrow_t&) throw()
+void operator delete(void* p, const std::nothrow_t&) TEST_NOEXCEPT
{
++unsized_delete_nothrow_called;
std::free(p);
}
-void operator delete(void* p, std::size_t) throw()
+void operator delete(void* p, std::size_t) TEST_NOEXCEPT
{
++sized_delete_called;
std::free(p);
}
+int* volatile x;
+
int main()
{
- int *x = new int(42);
+ x = new int(42);
assert(0 == sized_delete_called);
assert(0 == unsized_delete_called);
assert(0 == unsized_delete_nothrow_called);
diff --git a/test/std/language.support/support.exception/except.nested/assign.pass.cpp b/test/std/language.support/support.exception/except.nested/assign.pass.cpp
index a5508d1436fa..6338c8aaa26e 100644
--- a/test/std/language.support/support.exception/except.nested/assign.pass.cpp
+++ b/test/std/language.support/support.exception/except.nested/assign.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <exception>
// class nested_exception;
@@ -17,6 +16,8 @@
#include <exception>
#include <cassert>
+#include "test_macros.h"
+
class A
{
int data_;
@@ -34,6 +35,7 @@ int main()
e = e0;
assert(e.nested_ptr() == nullptr);
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
try
{
@@ -57,4 +59,5 @@ int main()
}
}
}
+#endif
}
diff --git a/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp b/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
index f9f293300e62..4cbdbb2ec892 100644
--- a/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
+++ b/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <exception>
// class nested_exception;
@@ -17,6 +16,8 @@
#include <exception>
#include <cassert>
+#include "test_macros.h"
+
class A
{
int data_;
@@ -33,6 +34,7 @@ int main()
std::nested_exception e = e0;
assert(e.nested_ptr() == nullptr);
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
try
{
@@ -55,4 +57,5 @@ int main()
}
}
}
+#endif
}
diff --git a/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp b/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
index 67766aa2c461..18ca9968ff56 100644
--- a/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
+++ b/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <exception>
// class nested_exception;
@@ -17,6 +16,8 @@
#include <exception>
#include <cassert>
+#include "test_macros.h"
+
class A
{
int data_;
@@ -32,6 +33,7 @@ int main()
std::nested_exception e;
assert(e.nested_ptr() == nullptr);
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
try
{
@@ -53,4 +55,5 @@ int main()
}
}
}
+#endif
}
diff --git a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
index 4ee95fdf3001..57d193a411cc 100644
--- a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
+++ b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <exception>
// class nested_exception;
@@ -18,12 +18,14 @@
#include <cstdlib>
#include <cassert>
+#include "test_macros.h"
+
class A
{
int data_;
public:
explicit A(int data) : data_(data) {}
- virtual ~A() _NOEXCEPT {}
+ virtual ~A() TEST_NOEXCEPT {}
friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
};
diff --git a/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
index 13c1dfe59311..d511a72f9f57 100644
--- a/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
+++ b/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <exception>
// class nested_exception;
diff --git a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
index c14cb69bdea3..a86d8bcbe201 100644
--- a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
+++ b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <exception>
// class nested_exception;
diff --git a/test/std/language.support/support.exception/propagation/current_exception.pass.cpp b/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
index 7bf1df457dbe..661f789fefd7 100644
--- a/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
+++ b/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <exception>
// exception_ptr current_exception();
diff --git a/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
index 6e4c0a98b09f..36feda7304bc 100644
--- a/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
+++ b/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <exception>
// template<class E> exception_ptr make_exception_ptr(E e);
diff --git a/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
index c28c901bdd73..565166cbdf76 100644
--- a/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
+++ b/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <exception>
// void rethrow_exception [[noreturn]] (exception_ptr p);
diff --git a/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp b/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
index 573d85bd242c..a4353be4f4cc 100644
--- a/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
+++ b/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// test uncaught_exception
#include <exception>
diff --git a/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp b/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
index b35ad7313bcc..b92671588027 100644
--- a/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
+++ b/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// test uncaught_exceptions
#include <exception>
diff --git a/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp b/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
index 2f0720639c66..e51ef7bd9230 100644
--- a/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
+++ b/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp
@@ -15,6 +15,9 @@
#include <initializer_list>
#include <cassert>
+#include <cstddef>
+
+#include "test_macros.h"
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -25,14 +28,14 @@ struct A
const int* b = il.begin();
const int* e = il.end();
assert(il.size() == 3);
- assert(e - b == il.size());
+ assert(static_cast<std::size_t>(e - b) == il.size());
assert(*b++ == 3);
assert(*b++ == 2);
assert(*b++ == 1);
}
};
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
struct B
{
constexpr B(std::initializer_list<int> il)
@@ -40,14 +43,14 @@ struct B
const int* b = il.begin();
const int* e = il.end();
assert(il.size() == 3);
- assert(e - b == il.size());
+ assert(static_cast<std::size_t>(e - b) == il.size());
assert(*b++ == 3);
assert(*b++ == 2);
assert(*b++ == 1);
}
};
-#endif // _LIBCPP_STD_VER > 11
+#endif // TEST_STD_VER > 11
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -56,7 +59,7 @@ int main()
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
A test1 = {3, 2, 1};
#endif
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
constexpr B test2 = {3, 2, 1};
-#endif // _LIBCPP_STD_VER > 11
+#endif // TEST_STD_VER > 11
}
diff --git a/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp b/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
index 7822a62206a1..e091834340aa 100644
--- a/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
+++ b/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp
@@ -14,6 +14,8 @@
#include <initializer_list>
#include <cassert>
+#include "test_macros.h"
+
struct A {};
int main()
@@ -22,8 +24,8 @@ int main()
std::initializer_list<A> il;
assert(il.size() == 0);
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
constexpr std::initializer_list<A> il2;
static_assert(il2.size() == 0, "");
-#endif // _LIBCPP_STD_VER > 11
+#endif // TEST_STD_VER > 11
}
diff --git a/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp b/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
index 5fcd28f9156c..938025d385fa 100644
--- a/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
+++ b/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
@@ -13,6 +13,9 @@
#include <initializer_list>
#include <cassert>
+#include <cstddef>
+
+#include "test_macros.h"
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -23,14 +26,14 @@ struct A
const int* b = begin(il);
const int* e = end(il);
assert(il.size() == 3);
- assert(e - b == il.size());
+ assert(static_cast<std::size_t>(e - b) == il.size());
assert(*b++ == 3);
assert(*b++ == 2);
assert(*b++ == 1);
}
};
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
struct B
{
constexpr B(std::initializer_list<int> il)
@@ -38,14 +41,14 @@ struct B
const int* b = begin(il);
const int* e = end(il);
assert(il.size() == 3);
- assert(e - b == il.size());
+ assert(static_cast<std::size_t>(e - b) == il.size());
assert(*b++ == 3);
assert(*b++ == 2);
assert(*b++ == 1);
}
};
-#endif // _LIBCPP_STD_VER > 11
+#endif // TEST_STD_VER > 11
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
int main()
@@ -53,7 +56,7 @@ int main()
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
A test1 = {3, 2, 1};
#endif
-#if _LIBCPP_STD_VER > 11
+#if TEST_STD_VER > 11
constexpr B test2 = {3, 2, 1};
-#endif // _LIBCPP_STD_VER > 11
+#endif // TEST_STD_VER > 11
}
diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
index a2ccca333cc6..033ecdc31af0 100644
--- a/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
+++ b/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
@@ -50,7 +50,7 @@ int main()
test<__int128_t>(0);
test<__uint128_t>(0);
#endif
- test<float>(1./zero);
+ test<float>(1.f/zero);
test<double>(1./zero);
test<long double>(1./zero);
}
diff --git a/test/std/language.support/support.runtime/cstdlib.pass.cpp b/test/std/language.support/support.runtime/cstdlib.pass.cpp
index d8f88cf58d9d..60f7d954db54 100644
--- a/test/std/language.support/support.runtime/cstdlib.pass.cpp
+++ b/test/std/language.support/support.runtime/cstdlib.pass.cpp
@@ -96,11 +96,9 @@ int main()
wchar_t* pw = 0;
const wchar_t* pwc = 0;
char* pc = 0;
-#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
static_assert((std::is_same<decltype(std::mblen("",0)), int>::value), "");
static_assert((std::is_same<decltype(std::mbtowc(pw,"",0)), int>::value), "");
static_assert((std::is_same<decltype(std::wctomb(pc,L' ')), int>::value), "");
-#endif
static_assert((std::is_same<decltype(std::mbstowcs(pw,"",0)), std::size_t>::value), "");
static_assert((std::is_same<decltype(std::wcstombs(pc,pwc,0)), std::size_t>::value), "");
}
diff --git a/test/std/language.support/support.types/nullptr_t.pass.cpp b/test/std/language.support/support.types/nullptr_t.pass.cpp
index ca5170f649ed..2d0ed7410590 100644
--- a/test/std/language.support/support.types/nullptr_t.pass.cpp
+++ b/test/std/language.support/support.types/nullptr_t.pass.cpp
@@ -11,6 +11,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
// typedef decltype(nullptr) nullptr_t;
struct A
@@ -34,22 +36,20 @@ void test_conversions()
}
}
+template <class T> struct Voider { typedef void type; };
+template <class T, class = void> struct has_less : std::false_type {};
+
+template <class T> struct has_less<T,
+ typename Voider<decltype(std::declval<T>() < nullptr)>::type> : std::true_type {};
+
template <class T>
void test_comparisons()
{
T p = nullptr;
assert(p == nullptr);
- assert(p <= nullptr);
- assert(p >= nullptr);
assert(!(p != nullptr));
- assert(!(p < nullptr));
- assert(!(p > nullptr));
assert(nullptr == p);
- assert(nullptr <= p);
- assert(nullptr >= p);
assert(!(nullptr != p));
- assert(!(nullptr < p));
- assert(!(nullptr > p));
}
#if defined(__clang__)
@@ -89,6 +89,15 @@ int main()
test_conversions<int A::*>();
}
{
+#ifdef _LIBCPP_HAS_NO_NULLPTR
+ static_assert(!has_less<std::nullptr_t>::value, "");
+ // FIXME: our c++03 nullptr emulation still allows for comparisons
+ // with other pointer types by way of the conversion operator.
+ //static_assert(!has_less<void*>::value, "");
+#else
+ // TODO Enable this assertion when all compilers implement core DR 583.
+ // static_assert(!has_less<std::nullptr_t>::value, "");
+#endif
test_comparisons<std::nullptr_t>();
test_comparisons<void*>();
test_comparisons<A*>();