From 53a420fba21cf1644972b34dcd811a43cdb8368d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 2 Jan 2017 19:18:58 +0000 Subject: Vendor import of libc++ trunk r290819: https://llvm.org/svn/llvm-project/libcxx/trunk@290819 --- .../support.dynamic/new_faligned_allocation.sh.cpp | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp (limited to 'test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp') diff --git a/test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp b/test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp new file mode 100644 index 000000000000..04b40009cda9 --- /dev/null +++ b/test/libcxx/language.support/support.dynamic/new_faligned_allocation.sh.cpp @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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 libc++'s implementation of align_val_t, and the relevent new/delete +// overloads in all dialects when -faligned-allocation is present. + +// REQUIRES: -faligned-allocation + +// RUN: %build -faligned-allocation +// RUN: %run + +#include +#include +#include +#include + +#include "test_macros.h" + +int main() { + { + static_assert(std::is_enum::value, ""); + typedef std::underlying_type::type UT; + static_assert((std::is_same::value), ""); + } + { + static_assert((!std::is_constructible::value), ""); +#if TEST_STD_VER >= 11 + static_assert(!std::is_constructible::value, ""); +#else + static_assert((std::is_constructible::value), ""); +#endif + } + { + std::align_val_t a = std::align_val_t(0); + std::align_val_t b = std::align_val_t(32); + assert(a != b); + assert(a == std::align_val_t(0)); + assert(b == std::align_val_t(32)); + } + { + void *ptr = ::operator new(1, std::align_val_t(128)); + assert(ptr); + assert(reinterpret_cast(ptr) % 128 == 0); + ::operator delete(ptr, std::align_val_t(128)); + } + { + void *ptr = ::operator new(1, std::align_val_t(128), std::nothrow); + assert(ptr); + assert(reinterpret_cast(ptr) % 128 == 0); + ::operator delete(ptr, std::align_val_t(128), std::nothrow); + } + { + void *ptr = ::operator new[](1, std::align_val_t(128)); + assert(ptr); + assert(reinterpret_cast(ptr) % 128 == 0); + ::operator delete[](ptr, std::align_val_t(128)); + } + { + void *ptr = ::operator new[](1, std::align_val_t(128), std::nothrow); + assert(ptr); + assert(reinterpret_cast(ptr) % 128 == 0); + ::operator delete[](ptr, std::align_val_t(128), std::nothrow); + } +#ifndef TEST_HAS_NO_RTTI + { + // Check that libc++ doesn't define align_val_t in a versioning namespace. + // And that it mangles the same in C++03 through C++17 + assert(typeid(std::align_val_t).name() == std::string("St11align_val_t")); + } +#endif +} \ No newline at end of file -- cgit v1.3