diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-06 18:46:46 +0000 | 
| commit | 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 (patch) | |
| tree | ec41ed70ffca97240e76f9a78bb2dedba28f310c /test/std/language.support | |
| parent | f857581820d15e410e9945d2fcd5f7163be25a96 (diff) | |
Notes
Diffstat (limited to 'test/std/language.support')
129 files changed, 6186 insertions, 0 deletions
diff --git a/test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp b/test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp new file mode 100644 index 000000000000..23cf8b66bcb1 --- /dev/null +++ b/test/std/language.support/cstdint/cstdint.syn/cstdint.pass.cpp @@ -0,0 +1,292 @@ +//===----------------------------------------------------------------------===// +// +//                     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 <cstdint> + +#include <cstdint> +#include <cstddef> +#include <cwchar> +#include <csignal> +#include <cwctype> +#include <climits> +#include <type_traits> +#include <limits> +#include <cassert> + +int main() +{ +    // typedef std::int8_t +    static_assert(sizeof(std::int8_t)*CHAR_BIT == 8, +                 "sizeof(std::int8_t)*CHAR_BIT == 8"); +    static_assert(std::is_signed<std::int8_t>::value, +                 "std::is_signed<std::int8_t>::value"); +    // typedef std::int16_t +    static_assert(sizeof(std::int16_t)*CHAR_BIT == 16, +                 "sizeof(std::int16_t)*CHAR_BIT == 16"); +    static_assert(std::is_signed<std::int16_t>::value, +                 "std::is_signed<std::int16_t>::value"); +    // typedef std::int32_t +    static_assert(sizeof(std::int32_t)*CHAR_BIT == 32, +                 "sizeof(std::int32_t)*CHAR_BIT == 32"); +    static_assert(std::is_signed<std::int32_t>::value, +                 "std::is_signed<std::int32_t>::value"); +    // typedef std::int64_t +    static_assert(sizeof(std::int64_t)*CHAR_BIT == 64, +                 "sizeof(std::int64_t)*CHAR_BIT == 64"); +    static_assert(std::is_signed<std::int64_t>::value, +                 "std::is_signed<std::int64_t>::value"); + +    // typedef std::uint8_t +    static_assert(sizeof(std::uint8_t)*CHAR_BIT == 8, +                 "sizeof(std::uint8_t)*CHAR_BIT == 8"); +    static_assert(std::is_unsigned<std::uint8_t>::value, +                 "std::is_unsigned<std::uint8_t>::value"); +    // typedef std::uint16_t +    static_assert(sizeof(std::uint16_t)*CHAR_BIT == 16, +                 "sizeof(std::uint16_t)*CHAR_BIT == 16"); +    static_assert(std::is_unsigned<std::uint16_t>::value, +                 "std::is_unsigned<std::uint16_t>::value"); +    // typedef std::uint32_t +    static_assert(sizeof(std::uint32_t)*CHAR_BIT == 32, +                 "sizeof(std::uint32_t)*CHAR_BIT == 32"); +    static_assert(std::is_unsigned<std::uint32_t>::value, +                 "std::is_unsigned<std::uint32_t>::value"); +    // typedef std::uint64_t +    static_assert(sizeof(std::uint64_t)*CHAR_BIT == 64, +                 "sizeof(std::uint64_t)*CHAR_BIT == 64"); +    static_assert(std::is_unsigned<std::uint64_t>::value, +                 "std::is_unsigned<std::uint64_t>::value"); + +    // typedef std::int_least8_t +    static_assert(sizeof(std::int_least8_t)*CHAR_BIT >= 8, +                 "sizeof(std::int_least8_t)*CHAR_BIT >= 8"); +    static_assert(std::is_signed<std::int_least8_t>::value, +                 "std::is_signed<std::int_least8_t>::value"); +    // typedef std::int_least16_t +    static_assert(sizeof(std::int_least16_t)*CHAR_BIT >= 16, +                 "sizeof(std::int_least16_t)*CHAR_BIT >= 16"); +    static_assert(std::is_signed<std::int_least16_t>::value, +                 "std::is_signed<std::int_least16_t>::value"); +    // typedef std::int_least32_t +    static_assert(sizeof(std::int_least32_t)*CHAR_BIT >= 32, +                 "sizeof(std::int_least32_t)*CHAR_BIT >= 32"); +    static_assert(std::is_signed<std::int_least32_t>::value, +                 "std::is_signed<std::int_least32_t>::value"); +    // typedef std::int_least64_t +    static_assert(sizeof(std::int_least64_t)*CHAR_BIT >= 64, +                 "sizeof(std::int_least64_t)*CHAR_BIT >= 64"); +    static_assert(std::is_signed<std::int_least64_t>::value, +                 "std::is_signed<std::int_least64_t>::value"); + +    // typedef std::uint_least8_t +    static_assert(sizeof(std::uint_least8_t)*CHAR_BIT >= 8, +                 "sizeof(std::uint_least8_t)*CHAR_BIT >= 8"); +    static_assert(std::is_unsigned<std::uint_least8_t>::value, +                 "std::is_unsigned<std::uint_least8_t>::value"); +    // typedef std::uint_least16_t +    static_assert(sizeof(std::uint_least16_t)*CHAR_BIT >= 16, +                 "sizeof(std::uint_least16_t)*CHAR_BIT >= 16"); +    static_assert(std::is_unsigned<std::uint_least16_t>::value, +                 "std::is_unsigned<std::uint_least16_t>::value"); +    // typedef std::uint_least32_t +    static_assert(sizeof(std::uint_least32_t)*CHAR_BIT >= 32, +                 "sizeof(std::uint_least32_t)*CHAR_BIT >= 32"); +    static_assert(std::is_unsigned<std::uint_least32_t>::value, +                 "std::is_unsigned<std::uint_least32_t>::value"); +    // typedef std::uint_least64_t +    static_assert(sizeof(std::uint_least64_t)*CHAR_BIT >= 64, +                 "sizeof(std::uint_least64_t)*CHAR_BIT >= 64"); +    static_assert(std::is_unsigned<std::uint_least64_t>::value, +                 "std::is_unsigned<std::uint_least64_t>::value"); + +    // typedef std::int_fast8_t +    static_assert(sizeof(std::int_fast8_t)*CHAR_BIT >= 8, +                 "sizeof(std::int_fast8_t)*CHAR_BIT >= 8"); +    static_assert(std::is_signed<std::int_fast8_t>::value, +                 "std::is_signed<std::int_fast8_t>::value"); +    // typedef std::int_fast16_t +    static_assert(sizeof(std::int_fast16_t)*CHAR_BIT >= 16, +                 "sizeof(std::int_fast16_t)*CHAR_BIT >= 16"); +    static_assert(std::is_signed<std::int_fast16_t>::value, +                 "std::is_signed<std::int_fast16_t>::value"); +    // typedef std::int_fast32_t +    static_assert(sizeof(std::int_fast32_t)*CHAR_BIT >= 32, +                 "sizeof(std::int_fast32_t)*CHAR_BIT >= 32"); +    static_assert(std::is_signed<std::int_fast32_t>::value, +                 "std::is_signed<std::int_fast32_t>::value"); +    // typedef std::int_fast64_t +    static_assert(sizeof(std::int_fast64_t)*CHAR_BIT >= 64, +                 "sizeof(std::int_fast64_t)*CHAR_BIT >= 64"); +    static_assert(std::is_signed<std::int_fast64_t>::value, +                 "std::is_signed<std::int_fast64_t>::value"); + +    // typedef std::uint_fast8_t +    static_assert(sizeof(std::uint_fast8_t)*CHAR_BIT >= 8, +                 "sizeof(std::uint_fast8_t)*CHAR_BIT >= 8"); +    static_assert(std::is_unsigned<std::uint_fast8_t>::value, +                 "std::is_unsigned<std::uint_fast8_t>::value"); +    // typedef std::uint_fast16_t +    static_assert(sizeof(std::uint_fast16_t)*CHAR_BIT >= 16, +                 "sizeof(std::uint_fast16_t)*CHAR_BIT >= 16"); +    static_assert(std::is_unsigned<std::uint_fast16_t>::value, +                 "std::is_unsigned<std::uint_fast16_t>::value"); +    // typedef std::uint_fast32_t +    static_assert(sizeof(std::uint_fast32_t)*CHAR_BIT >= 32, +                 "sizeof(std::uint_fast32_t)*CHAR_BIT >= 32"); +    static_assert(std::is_unsigned<std::uint_fast32_t>::value, +                 "std::is_unsigned<std::uint_fast32_t>::value"); +    // typedef std::uint_fast64_t +    static_assert(sizeof(std::uint_fast64_t)*CHAR_BIT >= 64, +                 "sizeof(std::uint_fast64_t)*CHAR_BIT >= 64"); +    static_assert(std::is_unsigned<std::uint_fast64_t>::value, +                 "std::is_unsigned<std::uint_fast64_t>::value"); + +    // typedef std::intptr_t +    static_assert(sizeof(std::intptr_t) >= sizeof(void*), +                 "sizeof(std::intptr_t) >= sizeof(void*)"); +    static_assert(std::is_signed<std::intptr_t>::value, +                 "std::is_signed<std::intptr_t>::value"); +    // typedef std::uintptr_t +    static_assert(sizeof(std::uintptr_t) >= sizeof(void*), +                 "sizeof(std::uintptr_t) >= sizeof(void*)"); +    static_assert(std::is_unsigned<std::uintptr_t>::value, +                 "std::is_unsigned<std::uintptr_t>::value"); + +    // typedef std::intmax_t +    static_assert(sizeof(std::intmax_t) >= sizeof(long long), +                 "sizeof(std::intmax_t) >= sizeof(long long)"); +    static_assert(std::is_signed<std::intmax_t>::value, +                 "std::is_signed<std::intmax_t>::value"); +    // typedef std::uintmax_t +    static_assert(sizeof(std::uintmax_t) >= sizeof(unsigned long long), +                 "sizeof(std::uintmax_t) >= sizeof(unsigned long long)"); +    static_assert(std::is_unsigned<std::uintmax_t>::value, +                 "std::is_unsigned<std::uintmax_t>::value"); + +    // INTN_MIN +    static_assert(INT8_MIN == -128, "INT8_MIN == -128"); +    static_assert(INT16_MIN == -32768, "INT16_MIN == -32768"); +    static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648"); +    static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL"); + +    // INTN_MAX +    static_assert(INT8_MAX == 127, "INT8_MAX == 127"); +    static_assert(INT16_MAX == 32767, "INT16_MAX == 32767"); +    static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647"); +    static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL"); + +    // UINTN_MAX +    static_assert(UINT8_MAX == 255, "UINT8_MAX == 255"); +    static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535"); +    static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295"); +    static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL"); + +    // INT_FASTN_MIN +    static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128"); +    static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768"); +    static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648"); +    static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL"); + +    // INT_FASTN_MAX +    static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127"); +    static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767"); +    static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647"); +    static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL"); + +    // UINT_FASTN_MAX +    static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255"); +    static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535"); +    static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295"); +    static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL"); + +    // INTPTR_MIN +    assert(INTPTR_MIN == std::numeric_limits<std::intptr_t>::min()); + +    // INTPTR_MAX +    assert(INTPTR_MAX == std::numeric_limits<std::intptr_t>::max()); + +    // UINTPTR_MAX +    assert(UINTPTR_MAX == std::numeric_limits<std::uintptr_t>::max()); + +    // INTMAX_MIN +    assert(INTMAX_MIN == std::numeric_limits<std::intmax_t>::min()); + +    // INTMAX_MAX +    assert(INTMAX_MAX == std::numeric_limits<std::intmax_t>::max()); + +    // UINTMAX_MAX +    assert(UINTMAX_MAX == std::numeric_limits<std::uintmax_t>::max()); + +    // PTRDIFF_MIN +    assert(PTRDIFF_MIN == std::numeric_limits<std::ptrdiff_t>::min()); + +    // PTRDIFF_MAX +    assert(PTRDIFF_MAX == std::numeric_limits<std::ptrdiff_t>::max()); + +    // SIG_ATOMIC_MIN +    assert(SIG_ATOMIC_MIN == std::numeric_limits<std::sig_atomic_t>::min()); + +    // SIG_ATOMIC_MAX +    assert(SIG_ATOMIC_MAX == std::numeric_limits<std::sig_atomic_t>::max()); + +    // SIZE_MAX +    assert(SIZE_MAX == std::numeric_limits<std::size_t>::max()); + +    // WCHAR_MIN +    assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min()); + +    // WCHAR_MAX +    assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max()); + +    // WINT_MIN +    assert(WINT_MIN == std::numeric_limits<std::wint_t>::min()); + +    // WINT_MAX +    assert(WINT_MAX == std::numeric_limits<std::wint_t>::max()); + +#ifndef INT8_C +#error INT8_C not defined +#endif + +#ifndef INT16_C +#error INT16_C not defined +#endif + +#ifndef INT32_C +#error INT32_C not defined +#endif + +#ifndef INT64_C +#error INT64_C not defined +#endif + +#ifndef UINT8_C +#error UINT8_C not defined +#endif + +#ifndef UINT16_C +#error UINT16_C not defined +#endif + +#ifndef UINT32_C +#error UINT32_C not defined +#endif + +#ifndef UINT64_C +#error UINT64_C not defined +#endif + +#ifndef INTMAX_C +#error INTMAX_C not defined +#endif + +#ifndef UINTMAX_C +#error UINTMAX_C not defined +#endif +} diff --git a/test/std/language.support/cstdint/version.pass.cpp b/test/std/language.support/cstdint/version.pass.cpp new file mode 100644 index 000000000000..4c9a43a62abc --- /dev/null +++ b/test/std/language.support/cstdint/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <cstdint> + +#include <cstdint> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/nothing_to_do.pass.cpp b/test/std/language.support/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp new file mode 100644 index 000000000000..cf8d4af93802 --- /dev/null +++ b/test/std/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +//                     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 bad_alloc + +#include <new> +#include <type_traits> +#include <cassert> + +int main() +{ +    static_assert((std::is_base_of<std::exception, std::bad_alloc>::value), +                 "std::is_base_of<std::exception, std::bad_alloc>::value"); +    static_assert(std::is_polymorphic<std::bad_alloc>::value, +                 "std::is_polymorphic<std::bad_alloc>::value"); +    std::bad_alloc b; +    std::bad_alloc b2 = b; +    b2 = b; +    const char* w = b2.what(); +    assert(w); +} diff --git a/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp new file mode 100644 index 000000000000..7de503304556 --- /dev/null +++ b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +//                     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 bad_array_length + +#include <new> +#include <type_traits> +#include <cassert> + +int main() +{ +#if __LIBCPP_STD_VER > 11 +    static_assert((std::is_base_of<std::bad_alloc, std::bad_array_length>::value), +                  "std::is_base_of<std::bad_alloc, std::bad_array_length>::value"); +    static_assert(std::is_polymorphic<std::bad_array_length>::value, +                 "std::is_polymorphic<std::bad_array_length>::value"); +    std::bad_array_length b; +    std::bad_array_length b2 = b; +    b2 = b; +    const char* w = b2.what(); +    assert(w); +#endif +} diff --git a/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp new file mode 100644 index 000000000000..50521c0005a5 --- /dev/null +++ b/test/std/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +//                     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 bad_array_new_length + +#include <new> +#include <type_traits> +#include <cassert> + +int main() +{ +    static_assert((std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value), +                  "std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value"); +    static_assert(std::is_polymorphic<std::bad_array_new_length>::value, +                 "std::is_polymorphic<std::bad_array_new_length>::value"); +    std::bad_array_new_length b; +    std::bad_array_new_length b2 = b; +    b2 = b; +    const char* w = b2.what(); +    assert(w); +} diff --git a/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp new file mode 100644 index 000000000000..6b799a3e83d8 --- /dev/null +++ b/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +//                     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 new_handler + +#include <new> + +void f() {} + +int main() +{ +    std::new_handler p = f; +} diff --git a/test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp new file mode 100644 index 000000000000..55a3edabfed8 --- /dev/null +++ b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +//                     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 get_new_handler + +#include <new> +#include <cassert> + +void f1() {} +void f2() {} + +int main() +{ +    assert(std::get_new_handler() == 0); +    std::set_new_handler(f1); +    assert(std::get_new_handler() == f1); +    std::set_new_handler(f2); +    assert(std::get_new_handler() == f2); +} diff --git a/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp new file mode 100644 index 000000000000..349bf440e0dc --- /dev/null +++ b/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +//                     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 set_new_handler + +#include <new> +#include <cassert> + +void f1() {} +void f2() {} + +int main() +{ +    assert(std::set_new_handler(f1) == 0); +    assert(std::set_new_handler(f2) == f1); +} 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 new file mode 100644 index 000000000000..5a87c0738784 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new[] +// NOTE: asan and msan will not call the new handler. +// UNSUPPORTED: sanitizer-new-delete + + +#include <new> +#include <cstddef> +#include <cassert> +#include <limits> + +int new_handler_called = 0; + +void new_handler() +{ +    ++new_handler_called; +    std::set_new_handler(0); +} + +int A_constructed = 0; + +struct A +{ +    A() {++A_constructed;} +    ~A() {--A_constructed;} +}; + +int main() +{ +    std::set_new_handler(new_handler); +    try +    { +        void*volatile vp = operator new[] (std::numeric_limits<std::size_t>::max()); +        assert(false); +    } +    catch (std::bad_alloc&) +    { +        assert(new_handler_called == 1); +    } +    catch (...) +    { +        assert(false); +    } +    A* ap = new A[3]; +    assert(ap); +    assert(A_constructed == 3); +    delete [] ap; +    assert(A_constructed == 0); +} 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 new file mode 100644 index 000000000000..b0db4a8e57e2 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new [] (nothrow) +// NOTE: asan and msan will not call the new handler. +// UNSUPPORTED: sanitizer-new-delete + + +#include <new> +#include <cstddef> +#include <cassert> +#include <limits> + +int new_handler_called = 0; + +void new_handler() +{ +    ++new_handler_called; +    std::set_new_handler(0); +} + +int A_constructed = 0; + +struct A +{ +    A() {++A_constructed;} +    ~A() {--A_constructed;} +}; + +int main() +{ +    std::set_new_handler(new_handler); +    try +    { +        void*volatile vp = operator new [] (std::numeric_limits<std::size_t>::max(), std::nothrow); +        assert(new_handler_called == 1); +        assert(vp == 0); +    } +    catch (...) +    { +        assert(false); +    } +    A* ap = new(std::nothrow) A[3]; +    assert(ap); +    assert(A_constructed == 3); +    delete [] ap; +    assert(A_constructed == 0); +} 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 new file mode 100644 index 000000000000..105c7a93f210 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new [] nothrow by replacing only operator new + +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> +#include <limits> + +int new_called = 0; + +void* operator new(std::size_t s) throw(std::bad_alloc) +{ +    ++new_called; +    return std::malloc(s); +} + +void  operator delete(void* p) throw() +{ +    --new_called; +    std::free(p); +} + +volatile int A_constructed = 0; + +struct A +{ +    A() {++A_constructed;} +    ~A() {--A_constructed;} +}; + +int main() +{ +    A* ap = new (std::nothrow) A[3]; +    assert(ap); +    assert(A_constructed == 3); +    assert(new_called); +    delete [] ap; +    assert(A_constructed == 0); +    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 new file mode 100644 index 000000000000..92bd7b952dcb --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new[] replacement by replacing only operator new + +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> +#include <limits> + +volatile int new_called = 0; + +void* operator new(std::size_t s) throw(std::bad_alloc) +{ +    ++new_called; +    return std::malloc(s); +} + +void  operator delete(void* p) throw() +{ +    --new_called; +    std::free(p); +} + +int A_constructed = 0; + +struct A +{ +    A() {++A_constructed;} +    ~A() {--A_constructed;} +}; + +int main() +{ +    A* ap = new A[3]; +    assert(ap); +    assert(A_constructed == 3); +    assert(new_called == 1); +    delete [] ap; +    assert(A_constructed == 0); +    assert(new_called == 0); +} 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 new file mode 100644 index 000000000000..0f7840ca9ef8 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array11.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +//                     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 sized operator delete[] replacement. + +// Note that sized delete operator definitions below are simply ignored +// when sized deallocation is not supported, e.g., prior to C++14. + +// UNSUPPORTED: c++14, c++1z +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int unsized_delete_called = 0; +int unsized_delete_nothrow_called = 0; +int sized_delete_called = 0; + +void operator delete[](void* p) throw() +{ +    ++unsized_delete_called; +    std::free(p); +} + +void operator delete[](void* p, const std::nothrow_t&) throw() +{ +    ++unsized_delete_nothrow_called; +    std::free(p); +} + +void operator delete[](void* p, std::size_t) throw() +{ +    ++sized_delete_called; +    std::free(p); +} + +// NOTE: Use a class with a non-trivial destructor as the test type in order +// to ensure the correct overload is called. +// C++14 5.3.5 [expr.delete]p10 +// - If the type is complete and if, for the second alternative (delete array) +//   only, the operand is a pointer to a class type with a non-trivial +//   destructor or a (possibly multi-dimensional) array thereof, the function +//   with two parameters is selected. +// - Otherwise, it is unspecified which of the two deallocation functions is +//   selected. +struct A { ~A() {} }; + +int main() +{ + +    A* x = new A[3]; +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +    assert(0 == sized_delete_called); + +    delete [] x; +    assert(1 == unsized_delete_called); +    assert(0 == sized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +} 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 new file mode 100644 index 000000000000..6447e29726c1 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +//                     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 sized operator delete[] replacement. + +// UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11 + +// TODO: Clang does not enable sized-deallocation in c++14 and behond by +// default. It is only enabled when -fsized-deallocation is given. +// (except clang-3.6 which temporarly enabled sized-deallocation) +// XFAIL: clang-3.4, clang-3.5, clang-3.7 +// XFAIL: apple-clang + +// NOTE: GCC 4.9.1 does not support sized-deallocation in c++14. However +// GCC 5.1 does. +// XFAIL: gcc-4.7, gcc-4.8, gcc-4.9 + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int unsized_delete_called = 0; +int unsized_delete_nothrow_called = 0; +int sized_delete_called = 0; + +void operator delete[](void* p) throw() +{ +    ++unsized_delete_called; +    std::free(p); +} + +void operator delete[](void* p, const std::nothrow_t&) throw() +{ +    ++unsized_delete_nothrow_called; +    std::free(p); +} + +void operator delete[](void* p, std::size_t) throw() +{ +    ++sized_delete_called; +    std::free(p); +} + +// NOTE: Use a class with a non-trivial destructor as the test type in order +// to ensure the correct overload is called. +// C++14 5.3.5 [expr.delete]p10 +// - If the type is complete and if, for the second alternative (delete array) +//   only, the operand is a pointer to a class type with a non-trivial +//   destructor or a (possibly multi-dimensional) array thereof, the function +//   with two parameters is selected. +// - Otherwise, it is unspecified which of the two deallocation functions is +//   selected. +struct A { ~A() {} }; + +int main() +{ +    A* x = new A[3]; +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +    assert(0 == sized_delete_called); + +    delete [] x; +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +    assert(1 == sized_delete_called); +} 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 new file mode 100644 index 000000000000..6d24aec35ef8 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +//                     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 sized operator [] delete calls the unsized operator [] delete. +// When sized operator delete [] is not available (ex C++11) then the unsized +// operator delete [] is called directly. + +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int delete_called = 0; +int delete_nothrow_called = 0; + +void operator delete[](void* p) throw() +{ +    ++delete_called; +    std::free(p); +} + +void operator delete[](void* p, const std::nothrow_t&) throw() +{ +    ++delete_nothrow_called; +    std::free(p); +} + +// NOTE: Use a class with a non-trivial destructor as the test type in order +// to ensure the correct overload is called. +// C++14 5.3.5 [expr.delete]p10 +// - If the type is complete and if, for the second alternative (delete array) +//   only, the operand is a pointer to a class type with a non-trivial +//   destructor or a (possibly multi-dimensional) array thereof, the function +//   with two parameters is selected. +// - Otherwise, it is unspecified which of the two deallocation functions is +//   selected. +struct A { ~A() {} }; + +int main() +{ +    A* x = new A[3]; +    assert(0 == delete_called); +    assert(0 == delete_nothrow_called); + +    delete [] x; +    assert(1 == delete_called); +    assert(0 == delete_nothrow_called); +} 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 new file mode 100644 index 000000000000..7dd510b4dac8 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_fsizeddeallocation.sh.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. +// +//===----------------------------------------------------------------------===// + +// test sized operator delete[] replacement. + +// Note that sized delete operator definitions below are simply ignored +// when sized deallocation is not supported, e.g., prior to C++14. + +// UNSUPPORTED: sanitizer-new-delete + +// NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation. +// REQUIRES: fsized-deallocation + +// RUN: %build -fsized-deallocation +// RUN: %run + +#if !defined(__cpp_sized_deallocation) +# error __cpp_sized_deallocation should be defined +#endif + +#if !(__cpp_sized_deallocation >= 201309L) +# error expected __cpp_sized_deallocation >= 201309L +#endif + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int unsized_delete_called = 0; +int unsized_delete_nothrow_called = 0; +int sized_delete_called = 0; + +void operator delete[](void* p) throw() +{ +    ++unsized_delete_called; +    std::free(p); +} + +void operator delete[](void* p, const std::nothrow_t&) throw() +{ +    ++unsized_delete_nothrow_called; +    std::free(p); +} + +void operator delete[](void* p, std::size_t) throw() +{ +    ++sized_delete_called; +    std::free(p); +} + +// NOTE: Use a class with a non-trivial destructor as the test type in order +// to ensure the correct overload is called. +// C++14 5.3.5 [expr.delete]p10 +// - If the type is complete and if, for the second alternative (delete array) +//   only, the operand is a pointer to a class type with a non-trivial +//   destructor or a (possibly multi-dimensional) array thereof, the function +//   with two parameters is selected. +// - Otherwise, it is unspecified which of the two deallocation functions is +//   selected. +struct A { ~A() {} }; + +int main() +{ +    A* x = new A[3]; +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +    assert(0 == sized_delete_called); + +    delete [] x; +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +    assert(1 == sized_delete_called); +} diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp new file mode 100644 index 000000000000..ad306e06cb78 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +//                     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 placement new + +#include <new> +#include <cassert> + +int A_constructed = 0; + +struct A +{ +    A() {++A_constructed;} +    ~A() {--A_constructed;} +}; + +int main() +{ +    char buf[sizeof(A)]; + +    A* ap = new(buf) A; +    assert((char*)ap == buf); +    assert(A_constructed == 1); +} diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp new file mode 100644 index 000000000000..1ab52ae4c8df --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +//                     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 placement new array + +#include <new> +#include <cassert> + +int A_constructed = 0; + +struct A +{ +    A() {++A_constructed;} +    ~A() {--A_constructed;} +}; + +int main() +{ +    char buf[3*sizeof(A)]; + +    A* ap = new(buf) A[3]; +    assert((char*)ap == buf); +    assert(A_constructed == 3); +} 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 new file mode 100644 index 000000000000..58aa3f2d529c --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new + +// asan and msan will not call the new handler. +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cassert> +#include <limits> + +int new_handler_called = 0; + +void new_handler() +{ +    ++new_handler_called; +    std::set_new_handler(0); +} + +bool A_constructed = false; + +struct A +{ +    A() {A_constructed = true;} +    ~A() {A_constructed = false;} +}; + +int main() +{ +    std::set_new_handler(new_handler); +    try +    { +        void* vp = operator new (std::numeric_limits<std::size_t>::max()); +        assert(false); +    } +    catch (std::bad_alloc&) +    { +        assert(new_handler_called == 1); +    } +    catch (...) +    { +        assert(false); +    } +    A* ap = new A; +    assert(ap); +    assert(A_constructed); +    delete ap; +    assert(!A_constructed); +} 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 new file mode 100644 index 000000000000..8c095ad32db4 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new (nothrow) + +// asan and msan will not call the new handler. +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cassert> +#include <limits> + +int new_handler_called = 0; + +void new_handler() +{ +    ++new_handler_called; +    std::set_new_handler(0); +} + +bool A_constructed = false; + +struct A +{ +    A() {A_constructed = true;} +    ~A() {A_constructed = false;} +}; + +int main() +{ +    std::set_new_handler(new_handler); +    try +    { +        void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::nothrow); +        assert(new_handler_called == 1); +        assert(vp == 0); +    } +    catch (...) +    { +        assert(false); +    } +    A* ap = new(std::nothrow) A; +    assert(ap); +    assert(A_constructed); +    delete 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 new file mode 100644 index 000000000000..cd70f90948d2 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new nothrow by replacing only operator new + +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> +#include <limits> + +int new_called = 0; + +void* operator new(std::size_t s) throw(std::bad_alloc) +{ +    ++new_called; +    return std::malloc(s); +} + +void  operator delete(void* p) throw() +{ +    --new_called; +    std::free(p); +} + +bool A_constructed = false; + +struct A +{ +    A() {A_constructed = true;} +    ~A() {A_constructed = false;} +}; + +int main() +{ +    A* ap = new (std::nothrow) A; +    assert(ap); +    assert(A_constructed); +    assert(new_called); +    delete 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 new file mode 100644 index 000000000000..0df3a93703d2 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +//                     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 operator new replacement + +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> +#include <limits> + +int new_called = 0; + +void* operator new(std::size_t s) throw(std::bad_alloc) +{ +    ++new_called; +    return std::malloc(s); +} + +void  operator delete(void* p) throw() +{ +    --new_called; +    std::free(p); +} + +bool A_constructed = false; + +struct A +{ +    A() {A_constructed = true;} +    ~A() {A_constructed = false;} +}; + +int main() +{ +    A* ap = new A; +    assert(ap); +    assert(A_constructed); +    assert(new_called); +    delete ap; +    assert(!A_constructed); +    assert(!new_called); +} 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 new file mode 100644 index 000000000000..e4064e2ab510 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +//                     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 sized operator delete replacement. + +// Note that sized delete operator definitions below are simply ignored +// when sized deallocation is not supported, e.g., prior to C++14. + +// UNSUPPORTED: c++14, c++1z +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int unsized_delete_called = 0; +int unsized_delete_nothrow_called = 0; +int sized_delete_called = 0; + +void operator delete(void* p) throw() +{ +    ++unsized_delete_called; +    std::free(p); +} + +void operator delete(void* p, const std::nothrow_t&) throw() +{ +    ++unsized_delete_nothrow_called; +    std::free(p); +} + +void operator delete(void* p, std::size_t) throw() +{ +    ++sized_delete_called; +    std::free(p); +} + +int main() +{ +    int *x = new int(42); +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +    assert(0 == sized_delete_called); + +    delete x; +    assert(1 == unsized_delete_called); +    assert(0 == sized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +} 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 new file mode 100644 index 000000000000..3c7f54fef726 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +//                     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 sized operator delete replacement. + +// UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11 + +// TODO: Clang does not enable sized-deallocation in c++14 and behond by +// default. It is only enabled when -fsized-deallocation is given. +// (except clang-3.6 which temporarly enabled sized-deallocation) +// XFAIL: clang-3.4, clang-3.5, clang-3.7 +// XFAIL: apple-clang + +// NOTE: GCC 4.9.1 does not support sized-deallocation in c++14. However +// GCC 5.1 does. +// XFAIL: gcc-4.7, gcc-4.8, gcc-4.9 + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int unsized_delete_called = 0; +int unsized_delete_nothrow_called = 0; +int sized_delete_called = 0; + +void operator delete(void* p) throw() +{ +    ++unsized_delete_called; +    std::free(p); +} + +void operator delete(void* p, const std::nothrow_t&) throw() +{ +    ++unsized_delete_nothrow_called; +    std::free(p); +} + +void operator delete(void* p, std::size_t) throw() +{ +    ++sized_delete_called; +    std::free(p); +} + +int main() +{ +    int *x = new int(42); +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +    assert(0 == sized_delete_called); + +    delete x; +    assert(0 == unsized_delete_called); +    assert(1 == sized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +} 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 new file mode 100644 index 000000000000..5c4eba53d3e4 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +//                     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 sized operator delete calls the unsized operator delete. +// When sized operator delete is not available (ex C++11) then the unsized +// operator delete is called directly. + +// UNSUPPORTED: sanitizer-new-delete + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int delete_called = 0; +int delete_nothrow_called = 0; + +void operator delete(void* p) throw() +{ +    ++delete_called; +    std::free(p); +} + +void operator delete(void* p, const std::nothrow_t&) throw() +{ +    ++delete_nothrow_called; +    std::free(p); +} + +int main() +{ +    int *x = new int(42); +    assert(0 == delete_called); +    assert(0 == delete_nothrow_called); + +    delete x; +    assert(1 == 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 new file mode 100644 index 000000000000..da43d4969174 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +//                     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 sized operator delete replacement. + +// Note that sized delete operator definitions below are simply ignored +// when sized deallocation is not supported, e.g., prior to C++14. + +// UNSUPPORTED: sanitizer-new-delete + +// NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation. +// REQUIRES: fsized-deallocation + +// RUN: %build -fsized-deallocation +// RUN: %run + +#if !defined(__cpp_sized_deallocation) +# error __cpp_sized_deallocation should be defined +#endif + +#if !(__cpp_sized_deallocation >= 201309L) +# error expected __cpp_sized_deallocation >= 201309L +#endif + +#include <new> +#include <cstddef> +#include <cstdlib> +#include <cassert> + +int unsized_delete_called = 0; +int unsized_delete_nothrow_called = 0; +int sized_delete_called = 0; + +void operator delete(void* p) throw() +{ +    ++unsized_delete_called; +    std::free(p); +} + +void operator delete(void* p, const std::nothrow_t&) throw() +{ +    ++unsized_delete_nothrow_called; +    std::free(p); +} + +void operator delete(void* p, std::size_t) throw() +{ +    ++sized_delete_called; +    std::free(p); +} + +int main() +{ +    int *x = new int(42); +    assert(0 == sized_delete_called); +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); + +    delete x; +    assert(1 == sized_delete_called); +    assert(0 == unsized_delete_called); +    assert(0 == unsized_delete_nothrow_called); +} diff --git a/test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp b/test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/language.support/support.dynamic/version.pass.cpp b/test/std/language.support/support.dynamic/version.pass.cpp new file mode 100644 index 000000000000..ba1ff518e51f --- /dev/null +++ b/test/std/language.support/support.dynamic/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <new> + +#include <new> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp b/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp new file mode 100644 index 000000000000..3baddaa898d0 --- /dev/null +++ b/test/std/language.support/support.exception/bad.exception/bad_exception.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +//                     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 bad_exception + +#include <exception> +#include <type_traits> +#include <cassert> + +int main() +{ +    static_assert((std::is_base_of<std::exception, std::bad_exception>::value), +                 "std::is_base_of<std::exception, std::bad_exception>::value"); +    static_assert(std::is_polymorphic<std::bad_exception>::value, +                 "std::is_polymorphic<std::bad_exception>::value"); +    std::bad_exception b; +    std::bad_exception b2 = b; +    b2 = b; +    const char* w = b2.what(); +    assert(w); +} 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 new file mode 100644 index 000000000000..cbe303c570d6 --- /dev/null +++ b/test/std/language.support/support.exception/except.nested/assign.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// class nested_exception; + +// nested_exception& operator=(const nested_exception&) throw() = default; + +#include <exception> +#include <cassert> + +class A +{ +    int data_; +public: +    explicit A(int data) : data_(data) {} + +    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} +}; + +int main() +{ +    { +        std::nested_exception e0; +        std::nested_exception e; +        e = e0; +        assert(e.nested_ptr() == nullptr); +    } +    { +        try +        { +            throw A(2); +            assert(false); +        } +        catch (const A&) +        { +            std::nested_exception e0; +            std::nested_exception e; +            e = e0; +            assert(e.nested_ptr() != nullptr); +            try +            { +                rethrow_exception(e.nested_ptr()); +                assert(false); +            } +            catch (const A& a) +            { +                assert(a == A(2)); +            } +        } +    } +} 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 new file mode 100644 index 000000000000..bfa13707a971 --- /dev/null +++ b/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// class nested_exception; + +// nested_exception(const nested_exception&) throw() = default; + +#include <exception> +#include <cassert> + +class A +{ +    int data_; +public: +    explicit A(int data) : data_(data) {} + +    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} +}; + +int main() +{ +    { +        std::nested_exception e0; +        std::nested_exception e = e0; +        assert(e.nested_ptr() == nullptr); +    } +    { +        try +        { +            throw A(2); +            assert(false); +        } +        catch (const A&) +        { +            std::nested_exception e0; +            std::nested_exception e = e0; +            assert(e.nested_ptr() != nullptr); +            try +            { +                rethrow_exception(e.nested_ptr()); +                assert(false); +            } +            catch (const A& a) +            { +                assert(a == A(2)); +            } +        } +    } +} 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 new file mode 100644 index 000000000000..1422f770eca8 --- /dev/null +++ b/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// class nested_exception; + +// nested_exception() throw(); + +#include <exception> +#include <cassert> + +class A +{ +    int data_; +public: +    explicit A(int data) : data_(data) {} + +    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} +}; + +int main() +{ +    { +        std::nested_exception e; +        assert(e.nested_ptr() == nullptr); +    } +    { +        try +        { +            throw A(2); +            assert(false); +        } +        catch (const A&) +        { +            std::nested_exception e; +            assert(e.nested_ptr() != nullptr); +            try +            { +                rethrow_exception(e.nested_ptr()); +                assert(false); +            } +            catch (const A& a) +            { +                assert(a == A(2)); +            } +        } +    } +} 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 new file mode 100644 index 000000000000..567ed579eb7b --- /dev/null +++ b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// class nested_exception; + +// template <class E> void rethrow_if_nested(const E& e); + +#include <exception> +#include <cstdlib> +#include <cassert> + +class A +{ +    int data_; +public: +    explicit A(int data) : data_(data) {} +    virtual ~A() _NOEXCEPT {} + +    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} +}; + +class B +    : public std::nested_exception, +      public A +{ +public: +    explicit B(int data) : A(data) {} +    B(const B& b) : A(b) {} +}; + +int main() +{ +    { +        try +        { +            A a(3); +            std::rethrow_if_nested(a); +            assert(true); +        } +        catch (...) +        { +            assert(false); +        } +    } +    { +        try +        { +            throw B(5); +        } +        catch (const B& b) +        { +            try +            { +                throw b; +            } +            catch (const A& a) +            { +                try +                { +                    std::rethrow_if_nested(a); +                    assert(false); +                } +                catch (const B& b) +                { +                    assert(b == B(5)); +                } +            } +        } +    } +    { +        try +        { +            std::rethrow_if_nested(1); +            assert(true); +        } +        catch (...) +        { +            assert(false); +        } +    } +} 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 new file mode 100644 index 000000000000..b07269061b4b --- /dev/null +++ b/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// class nested_exception; + +// void rethrow_nested [[noreturn]] () const; + +#include <exception> +#include <cstdlib> +#include <cassert> + +class A +{ +    int data_; +public: +    explicit A(int data) : data_(data) {} + +    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} +}; + +void go_quietly() +{ +    std::exit(0); +} + +int main() +{ +    { +        try +        { +            throw A(2); +            assert(false); +        } +        catch (const A&) +        { +            const std::nested_exception e; +            assert(e.nested_ptr() != nullptr); +            try +            { +                e.rethrow_nested(); +                assert(false); +            } +            catch (const A& a) +            { +                assert(a == A(2)); +            } +        } +    } +    { +        try +        { +            std::set_terminate(go_quietly); +            const std::nested_exception e; +            e.rethrow_nested(); +            assert(false); +        } +        catch (...) +        { +            assert(false); +        } +    } +} 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 new file mode 100644 index 000000000000..dad0df248076 --- /dev/null +++ b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp @@ -0,0 +1,119 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// class nested_exception; + +// template<class T> void throw_with_nested [[noreturn]] (T&& t); + +#include <exception> +#include <cstdlib> +#include <cassert> + +class A +{ +    int data_; +public: +    explicit A(int data) : data_(data) {} + +    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} +}; + +class B +    : public std::nested_exception +{ +    int data_; +public: +    explicit B(int data) : data_(data) {} + +    friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;} +}; + +#if __cplusplus > 201103L +struct Final final {}; +#endif + +int main() +{ +    { +        try +        { +            A a(3); +            std::throw_with_nested(a); +            assert(false); +        } +        catch (const A& a) +        { +            assert(a == A(3)); +        } +    } +    { +        try +        { +            A a(4); +            std::throw_with_nested(a); +            assert(false); +        } +        catch (const std::nested_exception& e) +        { +            assert(e.nested_ptr() == nullptr); +        } +    } +    { +        try +        { +            B b(5); +            std::throw_with_nested(b); +            assert(false); +        } +        catch (const B& b) +        { +            assert(b == B(5)); +        } +    } +    { +        try +        { +            B b(6); +            std::throw_with_nested(b); +            assert(false); +        } +        catch (const std::nested_exception& e) +        { +            assert(e.nested_ptr() == nullptr); +            const B& b = dynamic_cast<const B&>(e); +            assert(b == B(6)); +        } +    } +    { +        try +        { +            int i = 7; +            std::throw_with_nested(i); +            assert(false); +        } +        catch (int i) +        { +            assert(i == 7); +        } +    } +#if __cplusplus > 201103L +    { +        try +        { +            std::throw_with_nested(Final()); +            assert(false); +        } +        catch (const Final &f) +        { +        } +    } +#endif +} diff --git a/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp b/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp b/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp new file mode 100644 index 000000000000..82ae4aaa88d1 --- /dev/null +++ b/test/std/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +//                     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 get_terminate + +#include <exception> +#include <cstdlib> +#include <cassert> + +void f1() {} +void f2() {} + +int main() +{ +    std::set_terminate(f1); +    assert(std::get_terminate() == f1); +    std::set_terminate(f2); +    assert(std::get_terminate() == f2); +} diff --git a/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp b/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp new file mode 100644 index 000000000000..c4bff603ebb7 --- /dev/null +++ b/test/std/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +//                     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 set_terminate + +#include <exception> +#include <cstdlib> +#include <cassert> + +void f1() {} +void f2() {} + +int main() +{ +    std::set_terminate(f1); +    assert(std::set_terminate(f2) == f1); +} diff --git a/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp new file mode 100644 index 000000000000..232ce0a5a888 --- /dev/null +++ b/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +//                     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 terminate_handler + +#include <exception> + +void f() {} + +int main() +{ +    std::terminate_handler p = f; +} diff --git a/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp b/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp new file mode 100644 index 000000000000..3199d9b9ea90 --- /dev/null +++ b/test/std/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +//                     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 terminate + +#include <exception> +#include <cstdlib> +#include <cassert> + +void f1() +{ +    std::exit(0); +} + +int main() +{ +    std::set_terminate(f1); +    std::terminate(); +    assert(false); +} diff --git a/test/std/language.support/support.exception/exception/exception.pass.cpp b/test/std/language.support/support.exception/exception/exception.pass.cpp new file mode 100644 index 000000000000..ad53b6ebfe5a --- /dev/null +++ b/test/std/language.support/support.exception/exception/exception.pass.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +//                     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 exception + +#include <exception> +#include <type_traits> +#include <cassert> + +int main() +{ +    static_assert(std::is_polymorphic<std::exception>::value, +                 "std::is_polymorphic<std::exception>::value"); +    std::exception b; +    std::exception b2 = b; +    b2 = b; +    const char* w = b2.what(); +    assert(w); +} 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 new file mode 100644 index 000000000000..9ff0d6e2ce4d --- /dev/null +++ b/test/std/language.support/support.exception/propagation/current_exception.pass.cpp @@ -0,0 +1,269 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// exception_ptr current_exception(); + +#include <exception> +#include <cassert> + +struct A +{ +    static int constructed; + +    A() {++constructed;} +    ~A() {--constructed;} +    A(const A&)  {++constructed;} +}; + +int A::constructed = 0; + +int main() +{ +    { +        std::exception_ptr p = std::current_exception(); +        assert(p == nullptr); +    } +    { +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            assert(A::constructed == 1); +        } +        assert(A::constructed == 0); +    } +    assert(A::constructed == 0); +    { +        std::exception_ptr p2; +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            std::exception_ptr p = std::current_exception(); +            assert(A::constructed == 1); +            assert(p != nullptr); +            p2 = std::current_exception(); +            assert(A::constructed == 1); +            assert(p == p2); +        } +        assert(A::constructed == 1); +    } +    assert(A::constructed == 0); +    { +        std::exception_ptr p2; +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (A& a) +        { +            std::exception_ptr p = std::current_exception(); +            assert(A::constructed == 1); +            assert(p != nullptr); +            p2 = std::current_exception(); +            assert(A::constructed == 1); +            assert(p == p2); +        } +        assert(A::constructed == 1); +    } +    assert(A::constructed == 0); +    { +        std::exception_ptr p2; +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (A a) +        { +            std::exception_ptr p = std::current_exception(); +            assert(A::constructed == 2); +            assert(p != nullptr); +            p2 = std::current_exception(); +            assert(A::constructed == 2); +            assert(p == p2); +        } +        assert(A::constructed == 1); +    } +    assert(A::constructed == 0); +    { +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            assert(A::constructed == 1); +            try +            { +                assert(A::constructed == 1); +                throw; +                assert(false); +            } +            catch (...) +            { +                assert(A::constructed == 1); +            } +            assert(A::constructed == 1); +        } +        assert(A::constructed == 0); +    } +    assert(A::constructed == 0); +    { +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            assert(A::constructed == 1); +            try +            { +                std::exception_ptr p = std::current_exception(); +                assert(A::constructed == 1); +                assert(p != nullptr); +                throw; +                assert(false); +            } +            catch (...) +            { +                assert(A::constructed == 1); +            } +            assert(A::constructed == 1); +        } +        assert(A::constructed == 0); +    } +    assert(A::constructed == 0); +    { +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            assert(A::constructed == 1); +            try +            { +                assert(A::constructed == 1); +                throw; +                assert(false); +            } +            catch (...) +            { +                std::exception_ptr p = std::current_exception(); +                assert(A::constructed == 1); +                assert(p != nullptr); +            } +            assert(A::constructed == 1); +        } +        assert(A::constructed == 0); +    } +    assert(A::constructed == 0); +    { +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            assert(A::constructed == 1); +            try +            { +                assert(A::constructed == 1); +                throw; +                assert(false); +            } +            catch (...) +            { +                assert(A::constructed == 1); +            } +            std::exception_ptr p = std::current_exception(); +            assert(A::constructed == 1); +            assert(p != nullptr); +        } +        assert(A::constructed == 0); +    } +    assert(A::constructed == 0); +    { +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            assert(A::constructed == 1); +            try +            { +                assert(A::constructed == 1); +                throw; +                assert(false); +            } +            catch (...) +            { +                assert(A::constructed == 1); +            } +            assert(A::constructed == 1); +        } +        std::exception_ptr p = std::current_exception(); +        assert(A::constructed == 0); +        assert(p == nullptr); +    } +    assert(A::constructed == 0); +    { +        std::exception_ptr p; +        try +        { +            assert(A::constructed == 0); +            throw A(); +            assert(false); +        } +        catch (...) +        { +            assert(A::constructed == 1); +            try +            { +                assert(A::constructed == 1); +                throw; +                assert(false); +            } +            catch (...) +            { +                p = std::current_exception(); +                assert(A::constructed == 1); +            } +            assert(A::constructed == 1); +        } +        assert(A::constructed == 1); +        assert(p != nullptr); +    } +    assert(A::constructed == 0); +} diff --git a/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp b/test/std/language.support/support.exception/propagation/exception_ptr.pass.cpp new file mode 100644 index 000000000000..3aa8dcf55bbc --- /dev/null +++ b/test/std/language.support/support.exception/propagation/exception_ptr.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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// typedef unspecified exception_ptr; + +// exception_ptr shall satisfy the requirements of NullablePointer. + +#include <exception> +#include <cassert> + +int main() +{ +    std::exception_ptr p; +    assert(p == nullptr); +    std::exception_ptr p2 = p; +    assert(nullptr == p); +    assert(!p); +    assert(p2 == p); +    p2 = p; +    assert(p2 == p); +    assert(p2 == nullptr); +    std::exception_ptr p3 = nullptr; +    assert(p3 == nullptr); +    p3 = nullptr; +    assert(p3 == nullptr); +} 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 new file mode 100644 index 000000000000..89c9f85d3810 --- /dev/null +++ b/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// template<class E> exception_ptr make_exception_ptr(E e); + +#include <exception> +#include <cassert> + +struct A +{ +    static int constructed; +    int data_; + +    A(int data = 0) : data_(data) {++constructed;} +    ~A() {--constructed;} +    A(const A& a) : data_(a.data_) {++constructed;} +}; + +int A::constructed = 0; + +int main() +{ +    { +        std::exception_ptr p = std::make_exception_ptr(A(5)); +        try +        { +            std::rethrow_exception(p); +            assert(false); +        } +        catch (const A& a) +        { +            assert(A::constructed == 1); +            assert(p != nullptr); +            p = nullptr; +            assert(p == nullptr); +            assert(a.data_ == 5); +            assert(A::constructed == 1); +        } +        assert(A::constructed == 0); +    } +} 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 new file mode 100644 index 000000000000..e47a5989d41c --- /dev/null +++ b/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +// void rethrow_exception [[noreturn]] (exception_ptr p); + +#include <exception> +#include <cassert> + +struct A +{ +    static int constructed; +    int data_; + +    A(int data = 0) : data_(data) {++constructed;} +    ~A() {--constructed;} +    A(const A& a) : data_(a.data_) {++constructed;} +}; + +int A::constructed = 0; + +int main() +{ +    { +        std::exception_ptr p; +        try +        { +            throw A(3); +        } +        catch (...) +        { +            p = std::current_exception(); +        } +        try +        { +            std::rethrow_exception(p); +            assert(false); +        } +        catch (const A& a) +        { +            assert(A::constructed == 1); +            assert(p != nullptr); +            p = nullptr; +            assert(p == nullptr); +            assert(a.data_ == 3); +            assert(A::constructed == 1); +        } +        assert(A::constructed == 0); +    } +} 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 new file mode 100644 index 000000000000..22d8d8e982ae --- /dev/null +++ b/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +//                     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 uncaught_exception + +#include <exception> +#include <cassert> + +struct A +{ +    ~A() +    { +        assert(std::uncaught_exception()); +    } +}; + +struct B +{ +    B() +    { +        // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475 +        assert(!std::uncaught_exception()); +    } +}; + +int main() +{ +    try +    { +        A a; +        assert(!std::uncaught_exception()); +        throw B(); +    } +    catch (...) +    { +        assert(!std::uncaught_exception()); +    } +    assert(!std::uncaught_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 new file mode 100644 index 000000000000..1adc904fd5d2 --- /dev/null +++ b/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +//                     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 uncaught_exceptions + +#include <exception> +#include <cassert> + +struct A +{ +    ~A() +    { +        assert(std::uncaught_exceptions() > 0); +    } +}; + +struct B +{ +    B() +    { +        // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475 +        assert(std::uncaught_exceptions() == 0); +    } +}; + +int main() +{ +    try +    { +        A a; +        assert(std::uncaught_exceptions() == 0); +        throw B(); +    } +    catch (...) +    { +        assert(std::uncaught_exception() == 0); +    } +    assert(std::uncaught_exceptions() == 0); +} diff --git a/test/std/language.support/support.exception/version.pass.cpp b/test/std/language.support/support.exception/version.pass.cpp new file mode 100644 index 000000000000..acdedbb31fe3 --- /dev/null +++ b/test/std/language.support/support.exception/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <exception> + +#include <exception> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.general/nothing_to_do.pass.cpp b/test/std/language.support/support.general/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/support.general/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} 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 new file mode 100644 index 000000000000..2f0720639c66 --- /dev/null +++ b/test/std/language.support/support.initlist/support.initlist.access/access.pass.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// template<class E> class initializer_list; + +// const E* begin() const; +// const E* end() const; +// size_t size() const; + +#include <initializer_list> +#include <cassert> + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +struct A +{ +    A(std::initializer_list<int> il) +    { +        const int* b = il.begin(); +        const int* e = il.end(); +        assert(il.size() == 3); +        assert(e - b == il.size()); +        assert(*b++ == 3); +        assert(*b++ == 2); +        assert(*b++ == 1); +    } +}; + +#if _LIBCPP_STD_VER > 11 +struct B +{ +    constexpr B(std::initializer_list<int> il) +    { +        const int* b = il.begin(); +        const int* e = il.end(); +        assert(il.size() == 3); +        assert(e - b == il.size()); +        assert(*b++ == 3); +        assert(*b++ == 2); +        assert(*b++ == 1); +    } +}; + +#endif  // _LIBCPP_STD_VER > 11 + +#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +    A test1 = {3, 2, 1}; +#endif +#if _LIBCPP_STD_VER > 11 +    constexpr B test2 = {3, 2, 1}; +#endif  // _LIBCPP_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 new file mode 100644 index 000000000000..7822a62206a1 --- /dev/null +++ b/test/std/language.support/support.initlist/support.initlist.cons/default.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// template<class E> class initializer_list; + +// initializer_list(); + +#include <initializer_list> +#include <cassert> + +struct A {}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +    std::initializer_list<A> il; +    assert(il.size() == 0); +#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 +    constexpr std::initializer_list<A> il2; +    static_assert(il2.size() == 0, ""); +#endif  // _LIBCPP_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 new file mode 100644 index 000000000000..5fcd28f9156c --- /dev/null +++ b/test/std/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <initializer_list> + +// template<class E> const E* begin(initializer_list<E> il); + +#include <initializer_list> +#include <cassert> + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +struct A +{ +    A(std::initializer_list<int> il) +    { +        const int* b = begin(il); +        const int* e = end(il); +        assert(il.size() == 3); +        assert(e - b == il.size()); +        assert(*b++ == 3); +        assert(*b++ == 2); +        assert(*b++ == 1); +    } +}; + +#if _LIBCPP_STD_VER > 11 +struct B +{ +    constexpr B(std::initializer_list<int> il) +    { +        const int* b = begin(il); +        const int* e = end(il); +        assert(il.size() == 3); +        assert(e - b == il.size()); +        assert(*b++ == 3); +        assert(*b++ == 2); +        assert(*b++ == 1); +    } +}; + +#endif  // _LIBCPP_STD_VER > 11 +#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +    A test1 = {3, 2, 1}; +#endif +#if _LIBCPP_STD_VER > 11 +    constexpr B test2 = {3, 2, 1}; +#endif  // _LIBCPP_STD_VER > 11 +} diff --git a/test/std/language.support/support.initlist/types.pass.cpp b/test/std/language.support/support.initlist/types.pass.cpp new file mode 100644 index 000000000000..835830055ff4 --- /dev/null +++ b/test/std/language.support/support.initlist/types.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// template<class E> +// class initializer_list +// { +// public: +//     typedef E        value_type; +//     typedef const E& reference; +//     typedef const E& const_reference; +//     typedef size_t   size_type; +// +//     typedef const E* iterator; +//     typedef const E* const_iterator; + +#include <initializer_list> +#include <type_traits> + +struct A {}; + +int main() +{ +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +    static_assert((std::is_same<std::initializer_list<A>::value_type, A>::value), ""); +    static_assert((std::is_same<std::initializer_list<A>::reference, const A&>::value), ""); +    static_assert((std::is_same<std::initializer_list<A>::const_reference, const A&>::value), ""); +    static_assert((std::is_same<std::initializer_list<A>::size_type, std::size_t>::value), ""); +    static_assert((std::is_same<std::initializer_list<A>::iterator, const A*>::value), ""); +    static_assert((std::is_same<std::initializer_list<A>::const_iterator, const A*>::value), ""); +#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +} diff --git a/test/std/language.support/support.initlist/version.pass.cpp b/test/std/language.support/support.initlist/version.pass.cpp new file mode 100644 index 000000000000..f3f08cd1f864 --- /dev/null +++ b/test/std/language.support/support.initlist/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <initializer_list> + +#include <initializer_list> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp b/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp new file mode 100644 index 000000000000..5f63af68f701 --- /dev/null +++ b/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +//                     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 cfloat + +#include <cfloat> + +#ifndef FLT_ROUNDS +#error FLT_ROUNDS not defined +#endif + +#ifndef FLT_EVAL_METHOD +#error FLT_EVAL_METHOD not defined +#endif + +#ifndef FLT_RADIX +#error FLT_RADIX not defined +#endif + +#ifndef FLT_MANT_DIG +#error FLT_MANT_DIG not defined +#endif + +#ifndef DBL_MANT_DIG +#error DBL_MANT_DIG not defined +#endif + +#ifndef LDBL_MANT_DIG +#error LDBL_MANT_DIG not defined +#endif + +#ifndef DECIMAL_DIG +#error DECIMAL_DIG not defined +#endif + +#ifndef FLT_DIG +#error FLT_DIG not defined +#endif + +#ifndef DBL_DIG +#error DBL_DIG not defined +#endif + +#ifndef LDBL_DIG +#error LDBL_DIG not defined +#endif + +#ifndef FLT_MIN_EXP +#error FLT_MIN_EXP not defined +#endif + +#ifndef DBL_MIN_EXP +#error DBL_MIN_EXP not defined +#endif + +#ifndef LDBL_MIN_EXP +#error LDBL_MIN_EXP not defined +#endif + +#ifndef FLT_MIN_10_EXP +#error FLT_MIN_10_EXP not defined +#endif + +#ifndef DBL_MIN_10_EXP +#error DBL_MIN_10_EXP not defined +#endif + +#ifndef LDBL_MIN_10_EXP +#error LDBL_MIN_10_EXP not defined +#endif + +#ifndef FLT_MAX_EXP +#error FLT_MAX_EXP not defined +#endif + +#ifndef DBL_MAX_EXP +#error DBL_MAX_EXP not defined +#endif + +#ifndef LDBL_MAX_EXP +#error LDBL_MAX_EXP not defined +#endif + +#ifndef FLT_MAX_10_EXP +#error FLT_MAX_10_EXP not defined +#endif + +#ifndef DBL_MAX_10_EXP +#error DBL_MAX_10_EXP not defined +#endif + +#ifndef LDBL_MAX_10_EXP +#error LDBL_MAX_10_EXP not defined +#endif + +#ifndef FLT_MAX +#error FLT_MAX not defined +#endif + +#ifndef DBL_MAX +#error DBL_MAX not defined +#endif + +#ifndef LDBL_MAX +#error LDBL_MAX not defined +#endif + +#ifndef FLT_EPSILON +#error FLT_EPSILON not defined +#endif + +#ifndef DBL_EPSILON +#error DBL_EPSILON not defined +#endif + +#ifndef LDBL_EPSILON +#error LDBL_EPSILON not defined +#endif + +#ifndef FLT_MIN +#error FLT_MIN not defined +#endif + +#ifndef DBL_MIN +#error DBL_MIN not defined +#endif + +#ifndef LDBL_MIN +#error LDBL_MIN not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.limits/c.limits/climits.pass.cpp b/test/std/language.support/support.limits/c.limits/climits.pass.cpp new file mode 100644 index 000000000000..5e31b494bd1d --- /dev/null +++ b/test/std/language.support/support.limits/c.limits/climits.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +//                     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 climits + +#include <climits> + +#ifndef CHAR_BIT +#error CHAR_BIT not defined +#endif + +#ifndef SCHAR_MIN +#error SCHAR_MIN not defined +#endif + +#ifndef SCHAR_MAX +#error SCHAR_MAX not defined +#endif + +#ifndef UCHAR_MAX +#error UCHAR_MAX not defined +#endif + +#ifndef CHAR_MIN +#error CHAR_MIN not defined +#endif + +#ifndef CHAR_MAX +#error CHAR_MAX not defined +#endif + +#ifndef MB_LEN_MAX +#error MB_LEN_MAX not defined +#endif + +#ifndef SHRT_MIN +#error SHRT_MIN not defined +#endif + +#ifndef SHRT_MAX +#error SHRT_MAX not defined +#endif + +#ifndef USHRT_MAX +#error USHRT_MAX not defined +#endif + +#ifndef INT_MIN +#error INT_MIN not defined +#endif + +#ifndef INT_MAX +#error INT_MAX not defined +#endif + +#ifndef UINT_MAX +#error UINT_MAX not defined +#endif + +#ifndef LONG_MIN +#error LONG_MIN not defined +#endif + +#ifndef LONG_MAX +#error LONG_MAX not defined +#endif + +#ifndef ULONG_MAX +#error ULONG_MAX not defined +#endif + +#ifndef LLONG_MIN +#error LLONG_MIN not defined +#endif + +#ifndef LLONG_MAX +#error LLONG_MAX not defined +#endif + +#ifndef ULLONG_MAX +#error ULLONG_MAX not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp b/test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp new file mode 100644 index 000000000000..19b463199cd6 --- /dev/null +++ b/test/std/language.support/support.limits/c.limits/version_cfloat.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <cfloat> + +#include <cfloat> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.limits/c.limits/version_climits.pass.cpp b/test/std/language.support/support.limits/c.limits/version_climits.pass.cpp new file mode 100644 index 000000000000..3fe07a5174b3 --- /dev/null +++ b/test/std/language.support/support.limits/c.limits/version_climits.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <climits> + +#include <climits> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp b/test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp new file mode 100644 index 000000000000..c6731fcc8e92 --- /dev/null +++ b/test/std/language.support/support.limits/limits/denorm.style/check_values.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// float_round_style + +#include <limits> + +typedef char one; +struct two {one _[2];}; + +one test(std::float_round_style); +two test(int); + +int main() +{ +    static_assert(std::round_indeterminate == -1, +                 "std::round_indeterminate == -1"); +    static_assert(std::round_toward_zero == 0, +                 "std::round_toward_zero == 0"); +    static_assert(std::round_to_nearest == 1, +                 "std::round_to_nearest == 1"); +    static_assert(std::round_toward_infinity == 2, +                 "std::round_toward_infinity == 2"); +    static_assert(std::round_toward_neg_infinity == 3, +                 "std::round_toward_neg_infinity == 3"); +    static_assert(sizeof(test(std::round_to_nearest)) == 1, +                 "sizeof(test(std::round_to_nearest)) == 1"); +    static_assert(sizeof(test(1)) == 2, +                 "sizeof(test(1)) == 2"); +} diff --git a/test/std/language.support/support.limits/limits/is_specialized.pass.cpp b/test/std/language.support/support.limits/limits/is_specialized.pass.cpp new file mode 100644 index 000000000000..ff5c1a2c0b8d --- /dev/null +++ b/test/std/language.support/support.limits/limits/is_specialized.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// Specializations shall be provided for each arithmetic type, both floating +// point and integer, including bool. The member is_specialized shall be +// true for all such specializations of numeric_limits. + +// Non-arithmetic standard types, such as complex<T> (26.3.2), shall not +// have specializations. + +// From [numeric.limits]: + +// The value of each member of a specialization of numeric_limits on a cv +// -qualified type cv T shall be equal to the value of the corresponding +// member of the specialization on the unqualified type T. + +// More convenient to test it here. + +#include <limits> +#include <complex> + +template <class T> +void test() +{ +    static_assert(std::numeric_limits<T>::is_specialized, +                 "std::numeric_limits<T>::is_specialized"); +    static_assert(std::numeric_limits<const T>::is_specialized, +                 "std::numeric_limits<const T>::is_specialized"); +    static_assert(std::numeric_limits<volatile T>::is_specialized, +                 "std::numeric_limits<volatile T>::is_specialized"); +    static_assert(std::numeric_limits<const volatile T>::is_specialized, +                 "std::numeric_limits<const volatile T>::is_specialized"); +} + +int main() +{ +    test<bool>(); +    test<char>(); +    test<wchar_t>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(); +    test<char32_t>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<signed char>(); +    test<unsigned char>(); +    test<signed short>(); +    test<unsigned short>(); +    test<signed int>(); +    test<unsigned int>(); +    test<signed long>(); +    test<unsigned long>(); +    test<signed long long>(); +    test<unsigned long long>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(); +    test<__uint128_t>(); +#endif +    test<float>(); +    test<double>(); +    test<long double>(); +    static_assert(!std::numeric_limits<std::complex<double> >::is_specialized, +                 "!std::numeric_limits<std::complex<double> >::is_specialized"); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp new file mode 100644 index 000000000000..bbead15da64f --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp @@ -0,0 +1,199 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +#include <limits> + +/* +<limits>: +    numeric_limits +        is_specialized +        digits +        digits10 +        max_digits10 +        is_signed +        is_integer +        is_exact +        radix +        min_exponent +        min_exponent10 +        max_exponent +        max_exponent10 +        has_infinity +        has_quiet_NaN +        has_signaling_NaN +        has_denorm +        has_denorm_loss +        is_iec559 +        is_bounded +        is_modulo +        traps +        tinyness_before +        round_style +*/ + +template <class _Tp> +void test(const _Tp &) {} + +#define TEST_NUMERIC_LIMITS(type) \ +  test(std::numeric_limits<type>::is_specialized); \ +  test(std::numeric_limits<type>::digits); \ +  test(std::numeric_limits<type>::digits10); \ +  test(std::numeric_limits<type>::max_digits10); \ +  test(std::numeric_limits<type>::is_signed); \ +  test(std::numeric_limits<type>::is_integer); \ +  test(std::numeric_limits<type>::is_exact); \ +  test(std::numeric_limits<type>::radix); \ +  test(std::numeric_limits<type>::min_exponent); \ +  test(std::numeric_limits<type>::min_exponent10); \ +  test(std::numeric_limits<type>::max_exponent); \ +  test(std::numeric_limits<type>::max_exponent10); \ +  test(std::numeric_limits<type>::has_infinity); \ +  test(std::numeric_limits<type>::has_quiet_NaN); \ +  test(std::numeric_limits<type>::has_signaling_NaN); \ +  test(std::numeric_limits<type>::has_denorm); \ +  test(std::numeric_limits<type>::has_denorm_loss); \ +  test(std::numeric_limits<type>::is_iec559); \ +  test(std::numeric_limits<type>::is_bounded); \ +  test(std::numeric_limits<type>::is_modulo); \ +  test(std::numeric_limits<type>::traps); \ +  test(std::numeric_limits<type>::tinyness_before); \ +  test(std::numeric_limits<type>::round_style); + +struct other {}; + +int main() +{ +    // bool +    TEST_NUMERIC_LIMITS(bool) +    TEST_NUMERIC_LIMITS(const bool) +    TEST_NUMERIC_LIMITS(volatile bool) +    TEST_NUMERIC_LIMITS(const volatile bool) + +    // char +    TEST_NUMERIC_LIMITS(char) +    TEST_NUMERIC_LIMITS(const char) +    TEST_NUMERIC_LIMITS(volatile char) +    TEST_NUMERIC_LIMITS(const volatile char) + +    // signed char +    TEST_NUMERIC_LIMITS(signed char) +    TEST_NUMERIC_LIMITS(const signed char) +    TEST_NUMERIC_LIMITS(volatile signed char) +    TEST_NUMERIC_LIMITS(const volatile signed char) + +    // unsigned char +    TEST_NUMERIC_LIMITS(unsigned char) +    TEST_NUMERIC_LIMITS(const unsigned char) +    TEST_NUMERIC_LIMITS(volatile unsigned char) +    TEST_NUMERIC_LIMITS(const volatile unsigned char) + +    // wchar_t +    TEST_NUMERIC_LIMITS(wchar_t) +    TEST_NUMERIC_LIMITS(const wchar_t) +    TEST_NUMERIC_LIMITS(volatile wchar_t) +    TEST_NUMERIC_LIMITS(const volatile wchar_t) + +    // char16_t +    TEST_NUMERIC_LIMITS(char16_t) +    TEST_NUMERIC_LIMITS(const char16_t) +    TEST_NUMERIC_LIMITS(volatile char16_t) +    TEST_NUMERIC_LIMITS(const volatile char16_t) + +    // char32_t +    TEST_NUMERIC_LIMITS(char32_t) +    TEST_NUMERIC_LIMITS(const char32_t) +    TEST_NUMERIC_LIMITS(volatile char32_t) +    TEST_NUMERIC_LIMITS(const volatile char32_t) + +    // short +    TEST_NUMERIC_LIMITS(short) +    TEST_NUMERIC_LIMITS(const short) +    TEST_NUMERIC_LIMITS(volatile short) +    TEST_NUMERIC_LIMITS(const volatile short) + +    // int +    TEST_NUMERIC_LIMITS(int) +    TEST_NUMERIC_LIMITS(const int) +    TEST_NUMERIC_LIMITS(volatile int) +    TEST_NUMERIC_LIMITS(const volatile int) + +    // long +    TEST_NUMERIC_LIMITS(long) +    TEST_NUMERIC_LIMITS(const long) +    TEST_NUMERIC_LIMITS(volatile long) +    TEST_NUMERIC_LIMITS(const volatile long) + +#ifndef _LIBCPP_HAS_NO_INT128 +    TEST_NUMERIC_LIMITS(__int128_t) +    TEST_NUMERIC_LIMITS(const __int128_t) +    TEST_NUMERIC_LIMITS(volatile __int128_t) +    TEST_NUMERIC_LIMITS(const volatile __int128_t) +#endif + +    // long long +    TEST_NUMERIC_LIMITS(long long) +    TEST_NUMERIC_LIMITS(const long long) +    TEST_NUMERIC_LIMITS(volatile long long) +    TEST_NUMERIC_LIMITS(const volatile long long) + +    // unsigned short +    TEST_NUMERIC_LIMITS(unsigned short) +    TEST_NUMERIC_LIMITS(const unsigned short) +    TEST_NUMERIC_LIMITS(volatile unsigned short) +    TEST_NUMERIC_LIMITS(const volatile unsigned short) + +    // unsigned int +    TEST_NUMERIC_LIMITS(unsigned int) +    TEST_NUMERIC_LIMITS(const unsigned int) +    TEST_NUMERIC_LIMITS(volatile unsigned int) +    TEST_NUMERIC_LIMITS(const volatile unsigned int) + +    // unsigned long +    TEST_NUMERIC_LIMITS(unsigned long) +    TEST_NUMERIC_LIMITS(const unsigned long) +    TEST_NUMERIC_LIMITS(volatile unsigned long) +    TEST_NUMERIC_LIMITS(const volatile unsigned long) + +    // unsigned long long +    TEST_NUMERIC_LIMITS(unsigned long long) +    TEST_NUMERIC_LIMITS(const unsigned long long) +    TEST_NUMERIC_LIMITS(volatile unsigned long long) +    TEST_NUMERIC_LIMITS(const volatile unsigned long long) + +#ifndef _LIBCPP_HAS_NO_INT128 +    TEST_NUMERIC_LIMITS(__uint128_t) +    TEST_NUMERIC_LIMITS(const __uint128_t) +    TEST_NUMERIC_LIMITS(volatile __uint128_t) +    TEST_NUMERIC_LIMITS(const volatile __uint128_t) +#endif + +    // float +    TEST_NUMERIC_LIMITS(float) +    TEST_NUMERIC_LIMITS(const float) +    TEST_NUMERIC_LIMITS(volatile float) +    TEST_NUMERIC_LIMITS(const volatile float) +     +    // double +    TEST_NUMERIC_LIMITS(double) +    TEST_NUMERIC_LIMITS(const double) +    TEST_NUMERIC_LIMITS(volatile double) +    TEST_NUMERIC_LIMITS(const volatile double) +     +    // long double +    TEST_NUMERIC_LIMITS(long double) +    TEST_NUMERIC_LIMITS(const long double) +    TEST_NUMERIC_LIMITS(volatile long double) +    TEST_NUMERIC_LIMITS(const volatile long double) + +    // other +    TEST_NUMERIC_LIMITS(other) +    TEST_NUMERIC_LIMITS(const other) +    TEST_NUMERIC_LIMITS(volatile other) +    TEST_NUMERIC_LIMITS(const volatile other) +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp new file mode 100644 index 000000000000..a452d4e9949d --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// denorm_min() + +#include <limits> +#include <cassert> + +template <class T> +void +test(T expected) +{ +    assert(std::numeric_limits<T>::denorm_min() == expected); +    assert(std::numeric_limits<const T>::denorm_min() == expected); +    assert(std::numeric_limits<volatile T>::denorm_min() == expected); +    assert(std::numeric_limits<const volatile T>::denorm_min() == expected); +} + +int main() +{ +    test<bool>(false); +    test<char>(0); +    test<signed char>(0); +    test<unsigned char>(0); +    test<wchar_t>(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(0); +    test<char32_t>(0); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(0); +    test<unsigned short>(0); +    test<int>(0); +    test<unsigned int>(0); +    test<long>(0); +    test<unsigned long>(0); +    test<long long>(0); +    test<unsigned long long>(0); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(0); +    test<__uint128_t>(0); +#endif +    test<float>(__FLT_DENORM_MIN__); +    test<double>(__DBL_DENORM_MIN__); +    test<long double>(__LDBL_DENORM_MIN__); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp new file mode 100644 index 000000000000..2dfea084b11d --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// digits + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::digits == expected, "digits test 1"); +    static_assert(std::numeric_limits<const T>::digits == expected, "digits test 2"); +    static_assert(std::numeric_limits<volatile T>::digits == expected, "digits test 3"); +    static_assert(std::numeric_limits<const volatile T>::digits == expected, "digits test 4"); +} + +int main() +{ +    test<bool, 1>(); +    test<char, std::numeric_limits<char>::is_signed ? 7 : 8>(); +    test<signed char, 7>(); +    test<unsigned char, 8>(); +    test<wchar_t, std::numeric_limits<wchar_t>::is_signed ? sizeof(wchar_t)*8-1 : sizeof(wchar_t)*8>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 16>(); +    test<char32_t, 32>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 15>(); +    test<unsigned short, 16>(); +    test<int, 31>(); +    test<unsigned int, 32>(); +    test<long, sizeof(long) == 4 ? 31 : 63>(); +    test<unsigned long, sizeof(long) == 4 ? 32 : 64>(); +    test<long long, 63>(); +    test<unsigned long long, 64>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 127>(); +    test<__uint128_t, 128>(); +#endif +    test<float, FLT_MANT_DIG>(); +    test<double, DBL_MANT_DIG>(); +    test<long double, LDBL_MANT_DIG>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp new file mode 100644 index 000000000000..2c5302cd6334 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// digits10 + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::digits10 == expected, "digits10 test 1"); +    static_assert(std::numeric_limits<T>::is_bounded, "digits10 test 5"); +    static_assert(std::numeric_limits<const T>::digits10 == expected, "digits10 test 2"); +    static_assert(std::numeric_limits<const T>::is_bounded, "digits10 test 6"); +    static_assert(std::numeric_limits<volatile T>::digits10 == expected, "digits10 test 3"); +    static_assert(std::numeric_limits<volatile T>::is_bounded, "digits10 test 7"); +    static_assert(std::numeric_limits<const volatile T>::digits10 == expected, "digits10 test 4"); +    static_assert(std::numeric_limits<const volatile T>::is_bounded, "digits10 test 8"); +} + +int main() +{ +    test<bool, 0>(); +    test<char, 2>(); +    test<signed char, 2>(); +    test<unsigned char, 2>(); +    test<wchar_t, 5*sizeof(wchar_t)/2-1>();  // 4 -> 9 and 2 -> 4 +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 4>(); +    test<char32_t, 9>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 4>(); +    test<unsigned short, 4>(); +    test<int, 9>(); +    test<unsigned int, 9>(); +    test<long, sizeof(long) == 4 ? 9 : 18>(); +    test<unsigned long, sizeof(long) == 4 ? 9 : 19>(); +    test<long long, 18>(); +    test<unsigned long long, 19>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 38>(); +    test<__uint128_t, 38>(); +#endif +    test<float, FLT_DIG>(); +    test<double, DBL_DIG>(); +    test<long double, LDBL_DIG>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp new file mode 100644 index 000000000000..0cce4848187d --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// epsilon() + +#include <limits> +#include <cfloat> +#include <cassert> + +template <class T> +void +test(T expected) +{ +    assert(std::numeric_limits<T>::epsilon() == expected); +    assert(std::numeric_limits<const T>::epsilon() == expected); +    assert(std::numeric_limits<volatile T>::epsilon() == expected); +    assert(std::numeric_limits<const volatile T>::epsilon() == expected); +} + +int main() +{ +    test<bool>(false); +    test<char>(0); +    test<signed char>(0); +    test<unsigned char>(0); +    test<wchar_t>(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(0); +    test<char32_t>(0); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(0); +    test<unsigned short>(0); +    test<int>(0); +    test<unsigned int>(0); +    test<long>(0); +    test<unsigned long>(0); +    test<long long>(0); +    test<unsigned long long>(0); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(0); +    test<__uint128_t>(0); +#endif +    test<float>(FLT_EPSILON); +    test<double>(DBL_EPSILON); +    test<long double>(LDBL_EPSILON); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp new file mode 100644 index 000000000000..e61802054d18 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// has_denorm + +#include <limits> + +template <class T, std::float_denorm_style expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::has_denorm == expected, "has_denorm test 1"); +    static_assert(std::numeric_limits<const T>::has_denorm == expected, "has_denorm test 2"); +    static_assert(std::numeric_limits<volatile T>::has_denorm == expected, "has_denorm test 3"); +    static_assert(std::numeric_limits<const volatile T>::has_denorm == expected, "has_denorm test 4"); +} + +int main() +{ +    test<bool, std::denorm_absent>(); +    test<char, std::denorm_absent>(); +    test<signed char, std::denorm_absent>(); +    test<unsigned char, std::denorm_absent>(); +    test<wchar_t, std::denorm_absent>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, std::denorm_absent>(); +    test<char32_t, std::denorm_absent>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, std::denorm_absent>(); +    test<unsigned short, std::denorm_absent>(); +    test<int, std::denorm_absent>(); +    test<unsigned int, std::denorm_absent>(); +    test<long, std::denorm_absent>(); +    test<unsigned long, std::denorm_absent>(); +    test<long long, std::denorm_absent>(); +    test<unsigned long long, std::denorm_absent>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, std::denorm_absent>(); +    test<__uint128_t, std::denorm_absent>(); +#endif +    test<float, std::denorm_present>(); +    test<double, std::denorm_present>(); +    test<long double, std::denorm_present>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp new file mode 100644 index 000000000000..660ecf5036d3 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// has_denorm_loss + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::has_denorm_loss == expected, "has_denorm_loss test 1"); +    static_assert(std::numeric_limits<const T>::has_denorm_loss == expected, "has_denorm_loss test 2"); +    static_assert(std::numeric_limits<volatile T>::has_denorm_loss == expected, "has_denorm_loss test 3"); +    static_assert(std::numeric_limits<const volatile T>::has_denorm_loss == expected, "has_denorm_loss test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, false>(); +    test<signed char, false>(); +    test<unsigned char, false>(); +    test<wchar_t, false>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, false>(); +    test<char32_t, false>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, false>(); +    test<unsigned short, false>(); +    test<int, false>(); +    test<unsigned int, false>(); +    test<long, false>(); +    test<unsigned long, false>(); +    test<long long, false>(); +    test<unsigned long long, false>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, false>(); +    test<__uint128_t, false>(); +#endif +    test<float, false>(); +    test<double, false>(); +    test<long double, false>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp new file mode 100644 index 000000000000..f8ca2059d46a --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// has_infinity + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::has_infinity == expected, "has_infinity test 1"); +    static_assert(std::numeric_limits<const T>::has_infinity == expected, "has_infinity test 2"); +    static_assert(std::numeric_limits<volatile T>::has_infinity == expected, "has_infinity test 3"); +    static_assert(std::numeric_limits<const volatile T>::has_infinity == expected, "has_infinity test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, false>(); +    test<signed char, false>(); +    test<unsigned char, false>(); +    test<wchar_t, false>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, false>(); +    test<char32_t, false>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, false>(); +    test<unsigned short, false>(); +    test<int, false>(); +    test<unsigned int, false>(); +    test<long, false>(); +    test<unsigned long, false>(); +    test<long long, false>(); +    test<unsigned long long, false>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, false>(); +    test<__uint128_t, false>(); +#endif +    test<float, true>(); +    test<double, true>(); +    test<long double, true>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp new file mode 100644 index 000000000000..7592171695fb --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// has_quiet_NaN + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::has_quiet_NaN == expected, "has_quiet_NaN test 1"); +    static_assert(std::numeric_limits<const T>::has_quiet_NaN == expected, "has_quiet_NaN test 2"); +    static_assert(std::numeric_limits<volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 3"); +    static_assert(std::numeric_limits<const volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, false>(); +    test<signed char, false>(); +    test<unsigned char, false>(); +    test<wchar_t, false>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, false>(); +    test<char32_t, false>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, false>(); +    test<unsigned short, false>(); +    test<int, false>(); +    test<unsigned int, false>(); +    test<long, false>(); +    test<unsigned long, false>(); +    test<long long, false>(); +    test<unsigned long long, false>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, false>(); +    test<__uint128_t, false>(); +#endif +    test<float, true>(); +    test<double, true>(); +    test<long double, true>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp new file mode 100644 index 000000000000..d68cd5d78878 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// has_signaling_NaN + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::has_signaling_NaN == expected, "has_signaling_NaN test 1"); +    static_assert(std::numeric_limits<const T>::has_signaling_NaN == expected, "has_signaling_NaN test 2"); +    static_assert(std::numeric_limits<volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 3"); +    static_assert(std::numeric_limits<const volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, false>(); +    test<signed char, false>(); +    test<unsigned char, false>(); +    test<wchar_t, false>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, false>(); +    test<char32_t, false>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, false>(); +    test<unsigned short, false>(); +    test<int, false>(); +    test<unsigned int, false>(); +    test<long, false>(); +    test<unsigned long, false>(); +    test<long long, false>(); +    test<unsigned long long, false>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, false>(); +    test<__uint128_t, false>(); +#endif +    test<float, true>(); +    test<double, true>(); +    test<long double, true>(); +} 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 new file mode 100644 index 000000000000..a2ccca333cc6 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// infinity() + +#include <limits> +#include <cfloat> +#include <cassert> + +template <class T> +void +test(T expected) +{ +    assert(std::numeric_limits<T>::infinity() == expected); +    assert(std::numeric_limits<const T>::infinity() == expected); +    assert(std::numeric_limits<volatile T>::infinity() == expected); +    assert(std::numeric_limits<const volatile T>::infinity() == expected); +} + +extern float zero; + +int main() +{ +    test<bool>(false); +    test<char>(0); +    test<signed char>(0); +    test<unsigned char>(0); +    test<wchar_t>(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(0); +    test<char32_t>(0); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(0); +    test<unsigned short>(0); +    test<int>(0); +    test<unsigned int>(0); +    test<long>(0); +    test<unsigned long>(0); +    test<long long>(0); +    test<unsigned long long>(0); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(0); +    test<__uint128_t>(0); +#endif +    test<float>(1./zero); +    test<double>(1./zero); +    test<long double>(1./zero); +} + +float zero = 0; diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp new file mode 100644 index 000000000000..fa714d5d1506 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// is_bounded + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::is_bounded == expected, "is_bounded test 1"); +    static_assert(std::numeric_limits<const T>::is_bounded == expected, "is_bounded test 2"); +    static_assert(std::numeric_limits<volatile T>::is_bounded == expected, "is_bounded test 3"); +    static_assert(std::numeric_limits<const volatile T>::is_bounded == expected, "is_bounded test 4"); +} + +int main() +{ +    test<bool, true>(); +    test<char, true>(); +    test<signed char, true>(); +    test<unsigned char, true>(); +    test<wchar_t, true>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, true>(); +    test<char32_t, true>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, true>(); +    test<unsigned short, true>(); +    test<int, true>(); +    test<unsigned int, true>(); +    test<long, true>(); +    test<unsigned long, true>(); +    test<long long, true>(); +    test<unsigned long long, true>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, true>(); +    test<__uint128_t, true>(); +#endif +    test<float, true>(); +    test<double, true>(); +    test<long double, true>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp new file mode 100644 index 000000000000..b96a0e7fc5f5 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// is_exact + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::is_exact == expected, "is_exact test 1"); +    static_assert(std::numeric_limits<const T>::is_exact == expected, "is_exact test 2"); +    static_assert(std::numeric_limits<volatile T>::is_exact == expected, "is_exact test 3"); +    static_assert(std::numeric_limits<const volatile T>::is_exact == expected, "is_exact test 4"); +} + +int main() +{ +    test<bool, true>(); +    test<char, true>(); +    test<signed char, true>(); +    test<unsigned char, true>(); +    test<wchar_t, true>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, true>(); +    test<char32_t, true>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, true>(); +    test<unsigned short, true>(); +    test<int, true>(); +    test<unsigned int, true>(); +    test<long, true>(); +    test<unsigned long, true>(); +    test<long long, true>(); +    test<unsigned long long, true>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, true>(); +    test<__uint128_t, true>(); +#endif +    test<float, false>(); +    test<double, false>(); +    test<long double, false>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp new file mode 100644 index 000000000000..4408714c1a1d --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// is_iec559 + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::is_iec559 == expected, "is_iec559 test 1"); +    static_assert(std::numeric_limits<const T>::is_iec559 == expected, "is_iec559 test 2"); +    static_assert(std::numeric_limits<volatile T>::is_iec559 == expected, "is_iec559 test 3"); +    static_assert(std::numeric_limits<const volatile T>::is_iec559 == expected, "is_iec559 test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, false>(); +    test<signed char, false>(); +    test<unsigned char, false>(); +    test<wchar_t, false>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, false>(); +    test<char32_t, false>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, false>(); +    test<unsigned short, false>(); +    test<int, false>(); +    test<unsigned int, false>(); +    test<long, false>(); +    test<unsigned long, false>(); +    test<long long, false>(); +    test<unsigned long long, false>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, false>(); +    test<__uint128_t, false>(); +#endif +    test<float, true>(); +    test<double, true>(); +#if (defined(__ppc__) || defined(__ppc64__)) +    test<long double, false>(); +#else +    test<long double, true>(); +#endif +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp new file mode 100644 index 000000000000..79bc5867ec63 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// is_integer + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::is_integer == expected, "is_integer test 1"); +    static_assert(std::numeric_limits<const T>::is_integer == expected, "is_integer test 2"); +    static_assert(std::numeric_limits<volatile T>::is_integer == expected, "is_integer test 3"); +    static_assert(std::numeric_limits<const volatile T>::is_integer == expected, "is_integer test 4"); +} + +int main() +{ +    test<bool, true>(); +    test<char, true>(); +    test<signed char, true>(); +    test<unsigned char, true>(); +    test<wchar_t, true>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, true>(); +    test<char32_t, true>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, true>(); +    test<unsigned short, true>(); +    test<int, true>(); +    test<unsigned int, true>(); +    test<long, true>(); +    test<unsigned long, true>(); +    test<long long, true>(); +    test<unsigned long long, true>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, true>(); +    test<__uint128_t, true>(); +#endif +    test<float, false>(); +    test<double, false>(); +    test<long double, false>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp new file mode 100644 index 000000000000..6a609963d04c --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// is_modulo + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::is_modulo == expected, "is_modulo test 1"); +    static_assert(std::numeric_limits<const T>::is_modulo == expected, "is_modulo test 2"); +    static_assert(std::numeric_limits<volatile T>::is_modulo == expected, "is_modulo test 3"); +    static_assert(std::numeric_limits<const volatile T>::is_modulo == expected, "is_modulo test 4"); +} + +int main() +{ +    test<bool, false>(); +//    test<char, false>(); // don't know +    test<signed char, false>(); +    test<unsigned char, true>(); +//    test<wchar_t, false>(); // don't know +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, true>(); +    test<char32_t, true>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, false>(); +    test<unsigned short, true>(); +    test<int, false>(); +    test<unsigned int, true>(); +    test<long, false>(); +    test<unsigned long, true>(); +    test<long long, false>(); +    test<unsigned long long, true>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, false>(); +    test<__uint128_t, true>(); +#endif +    test<float, false>(); +    test<double, false>(); +    test<long double, false>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp new file mode 100644 index 000000000000..28570fd22790 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// is_signed + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::is_signed == expected, "is_signed test 1"); +    static_assert(std::numeric_limits<const T>::is_signed == expected, "is_signed test 2"); +    static_assert(std::numeric_limits<volatile T>::is_signed == expected, "is_signed test 3"); +    static_assert(std::numeric_limits<const volatile T>::is_signed == expected, "is_signed test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, char(-1) < char(0)>(); +    test<signed char, true>(); +    test<unsigned char, false>(); +    test<wchar_t, wchar_t(-1) < wchar_t(0)>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, false>(); +    test<char32_t, false>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, true>(); +    test<unsigned short, false>(); +    test<int, true>(); +    test<unsigned int, false>(); +    test<long, true>(); +    test<unsigned long, false>(); +    test<long long, true>(); +    test<unsigned long long, false>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, true>(); +    test<__uint128_t, false>(); +#endif +    test<float, true>(); +    test<double, true>(); +    test<long double, true>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp new file mode 100644 index 000000000000..21090aa9c4c1 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// lowest() + +#include <limits> +#include <climits> +#include <cwchar> +#include <cfloat> +#include <cassert> + +template <class T> +void +test(T expected) +{ +    assert(std::numeric_limits<T>::lowest() == expected); +    assert(std::numeric_limits<T>::is_bounded); +    assert(std::numeric_limits<const T>::lowest() == expected); +    assert(std::numeric_limits<const T>::is_bounded); +    assert(std::numeric_limits<volatile T>::lowest() == expected); +    assert(std::numeric_limits<volatile T>::is_bounded); +    assert(std::numeric_limits<const volatile T>::lowest() == expected); +    assert(std::numeric_limits<const volatile T>::is_bounded); +} + +int main() +{ +    test<bool>(false); +    test<char>(CHAR_MIN); +    test<signed char>(SCHAR_MIN); +    test<unsigned char>(0); +    test<wchar_t>(WCHAR_MIN); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(0); +    test<char32_t>(0); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(SHRT_MIN); +    test<unsigned short>(0); +    test<int>(INT_MIN); +    test<unsigned int>(0); +    test<long>(LONG_MIN); +    test<unsigned long>(0); +    test<long long>(LLONG_MIN); +    test<unsigned long long>(0); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1); +    test<__uint128_t>(0); +#endif +    test<float>(-FLT_MAX); +    test<double>(-DBL_MAX); +    test<long double>(-LDBL_MAX); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp new file mode 100644 index 000000000000..7517aaa192c1 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// max() + +#include <limits> +#include <climits> +#include <cwchar> +#include <cfloat> +#include <cassert> + +template <class T> +void +test(T expected) +{ +    assert(std::numeric_limits<T>::max() == expected); +    assert(std::numeric_limits<T>::is_bounded); +    assert(std::numeric_limits<const T>::max() == expected); +    assert(std::numeric_limits<const T>::is_bounded); +    assert(std::numeric_limits<volatile T>::max() == expected); +    assert(std::numeric_limits<volatile T>::is_bounded); +    assert(std::numeric_limits<const volatile T>::max() == expected); +    assert(std::numeric_limits<const volatile T>::is_bounded); +} + +int main() +{ +    test<bool>(true); +    test<char>(CHAR_MAX); +    test<signed char>(SCHAR_MAX); +    test<unsigned char>(UCHAR_MAX); +    test<wchar_t>(WCHAR_MAX); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(USHRT_MAX); +    test<char32_t>(UINT_MAX); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(SHRT_MAX); +    test<unsigned short>(USHRT_MAX); +    test<int>(INT_MAX); +    test<unsigned int>(UINT_MAX); +    test<long>(LONG_MAX); +    test<unsigned long>(ULONG_MAX); +    test<long long>(LLONG_MAX); +    test<unsigned long long>(ULLONG_MAX); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(__int128_t(__uint128_t(-1)/2)); +    test<__uint128_t>(__uint128_t(-1)); +#endif +    test<float>(FLT_MAX); +    test<double>(DBL_MAX); +    test<long double>(LDBL_MAX); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp new file mode 100644 index 000000000000..de771ebe3b42 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// max_digits10 + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::max_digits10 == expected, "max_digits10 test 1"); +    static_assert(std::numeric_limits<const T>::max_digits10 == expected, "max_digits10 test 2"); +    static_assert(std::numeric_limits<volatile T>::max_digits10 == expected, "max_digits10 test 3"); +    static_assert(std::numeric_limits<const volatile T>::max_digits10 == expected, "max_digits10 test 4"); +} + +int main() +{ +    test<bool, 0>(); +    test<char, 0>(); +    test<signed char, 0>(); +    test<unsigned char, 0>(); +    test<wchar_t, 0>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 0>(); +    test<char32_t, 0>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 0>(); +    test<unsigned short, 0>(); +    test<int, 0>(); +    test<unsigned int, 0>(); +    test<long, 0>(); +    test<unsigned long, 0>(); +    test<long long, 0>(); +    test<unsigned long long, 0>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 0>(); +    test<__uint128_t, 0>(); +#endif +    test<float, 2+(FLT_MANT_DIG * 30103)/100000>(); +    test<double, 2+(DBL_MANT_DIG * 30103)/100000>(); +    test<long double, 2+(LDBL_MANT_DIG * 30103)/100000>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp new file mode 100644 index 000000000000..6b61f7ba4331 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// max_exponent + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::max_exponent == expected, "max_exponent test 1"); +    static_assert(std::numeric_limits<const T>::max_exponent == expected, "max_exponent test 2"); +    static_assert(std::numeric_limits<volatile T>::max_exponent == expected, "max_exponent test 3"); +    static_assert(std::numeric_limits<const volatile T>::max_exponent == expected, "max_exponent test 4"); +} + +int main() +{ +    test<bool, 0>(); +    test<char, 0>(); +    test<signed char, 0>(); +    test<unsigned char, 0>(); +    test<wchar_t, 0>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 0>(); +    test<char32_t, 0>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 0>(); +    test<unsigned short, 0>(); +    test<int, 0>(); +    test<unsigned int, 0>(); +    test<long, 0>(); +    test<unsigned long, 0>(); +    test<long long, 0>(); +    test<unsigned long long, 0>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 0>(); +    test<__uint128_t, 0>(); +#endif +    test<float, FLT_MAX_EXP>(); +    test<double, DBL_MAX_EXP>(); +    test<long double, LDBL_MAX_EXP>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp new file mode 100644 index 000000000000..927585e9468b --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// max_exponent10 + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::max_exponent10 == expected, "max_exponent10 test 1"); +    static_assert(std::numeric_limits<const T>::max_exponent10 == expected, "max_exponent10 test 2"); +    static_assert(std::numeric_limits<volatile T>::max_exponent10 == expected, "max_exponent10 test 3"); +    static_assert(std::numeric_limits<const volatile T>::max_exponent10 == expected, "max_exponent10 test 4"); +} + +int main() +{ +    test<bool, 0>(); +    test<char, 0>(); +    test<signed char, 0>(); +    test<unsigned char, 0>(); +    test<wchar_t, 0>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 0>(); +    test<char32_t, 0>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 0>(); +    test<unsigned short, 0>(); +    test<int, 0>(); +    test<unsigned int, 0>(); +    test<long, 0>(); +    test<unsigned long, 0>(); +    test<long long, 0>(); +    test<unsigned long long, 0>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 0>(); +    test<__uint128_t, 0>(); +#endif +    test<float, FLT_MAX_10_EXP>(); +    test<double, DBL_MAX_10_EXP>(); +    test<long double, LDBL_MAX_10_EXP>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp new file mode 100644 index 000000000000..e72fbba10512 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// min() + +#include <limits> +#include <climits> +#include <cwchar> +#include <cfloat> +#include <cassert> + +template <class T> +void +test(T expected) +{ +    assert(std::numeric_limits<T>::min() == expected); +    assert(std::numeric_limits<T>::is_bounded || !std::numeric_limits<T>::is_signed); +    assert(std::numeric_limits<const T>::min() == expected); +    assert(std::numeric_limits<const T>::is_bounded || !std::numeric_limits<const T>::is_signed); +    assert(std::numeric_limits<volatile T>::min() == expected); +    assert(std::numeric_limits<volatile T>::is_bounded || !std::numeric_limits<volatile T>::is_signed); +    assert(std::numeric_limits<const volatile T>::min() == expected); +    assert(std::numeric_limits<const volatile T>::is_bounded || !std::numeric_limits<const volatile T>::is_signed); +} + +int main() +{ +    test<bool>(false); +    test<char>(CHAR_MIN); +    test<signed char>(SCHAR_MIN); +    test<unsigned char>(0); +    test<wchar_t>(WCHAR_MIN); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(0); +    test<char32_t>(0); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(SHRT_MIN); +    test<unsigned short>(0); +    test<int>(INT_MIN); +    test<unsigned int>(0); +    test<long>(LONG_MIN); +    test<unsigned long>(0); +    test<long long>(LLONG_MIN); +    test<unsigned long long>(0); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1); +    test<__uint128_t>(0); +#endif +    test<float>(FLT_MIN); +    test<double>(DBL_MIN); +    test<long double>(LDBL_MIN); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp new file mode 100644 index 000000000000..245e8441499d --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// min_exponent + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::min_exponent == expected, "min_exponent test 1"); +    static_assert(std::numeric_limits<const T>::min_exponent == expected, "min_exponent test 2"); +    static_assert(std::numeric_limits<volatile T>::min_exponent == expected, "min_exponent test 3"); +    static_assert(std::numeric_limits<const volatile T>::min_exponent == expected, "min_exponent test 4"); +} + +int main() +{ +    test<bool, 0>(); +    test<char, 0>(); +    test<signed char, 0>(); +    test<unsigned char, 0>(); +    test<wchar_t, 0>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 0>(); +    test<char32_t, 0>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 0>(); +    test<unsigned short, 0>(); +    test<int, 0>(); +    test<unsigned int, 0>(); +    test<long, 0>(); +    test<unsigned long, 0>(); +    test<long long, 0>(); +    test<unsigned long long, 0>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 0>(); +    test<__uint128_t, 0>(); +#endif +    test<float, FLT_MIN_EXP>(); +    test<double, DBL_MIN_EXP>(); +    test<long double, LDBL_MIN_EXP>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp new file mode 100644 index 000000000000..b54d46fd52e8 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// min_exponent10 + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::min_exponent10 == expected, "min_exponent10 test 1"); +    static_assert(std::numeric_limits<const T>::min_exponent10 == expected, "min_exponent10 test 2"); +    static_assert(std::numeric_limits<volatile T>::min_exponent10 == expected, "min_exponent10 test 3"); +    static_assert(std::numeric_limits<const volatile T>::min_exponent10 == expected, "min_exponent10 test 4"); +} + +int main() +{ +    test<bool, 0>(); +    test<char, 0>(); +    test<signed char, 0>(); +    test<unsigned char, 0>(); +    test<wchar_t, 0>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 0>(); +    test<char32_t, 0>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 0>(); +    test<unsigned short, 0>(); +    test<int, 0>(); +    test<unsigned int, 0>(); +    test<long, 0>(); +    test<unsigned long, 0>(); +    test<long long, 0>(); +    test<unsigned long long, 0>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 0>(); +    test<__uint128_t, 0>(); +#endif +    test<float, FLT_MIN_10_EXP>(); +    test<double, DBL_MIN_10_EXP>(); +    test<long double, LDBL_MIN_10_EXP>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp new file mode 100644 index 000000000000..97166f0c3209 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// quiet_NaN() + +#include <limits> +#include <cmath> +#include <type_traits> +#include <cassert> + +template <class T> +void +test_imp(std::true_type) +{ +    assert(std::isnan(std::numeric_limits<T>::quiet_NaN())); +    assert(std::isnan(std::numeric_limits<const T>::quiet_NaN())); +    assert(std::isnan(std::numeric_limits<volatile T>::quiet_NaN())); +    assert(std::isnan(std::numeric_limits<const volatile T>::quiet_NaN())); +} + +template <class T> +void +test_imp(std::false_type) +{ +    assert(std::numeric_limits<T>::quiet_NaN() == T()); +    assert(std::numeric_limits<const T>::quiet_NaN() == T()); +    assert(std::numeric_limits<volatile T>::quiet_NaN() == T()); +    assert(std::numeric_limits<const volatile T>::quiet_NaN() == T()); +} + +template <class T> +inline +void +test() +{ +    test_imp<T>(std::is_floating_point<T>()); +} + +int main() +{ +    test<bool>(); +    test<char>(); +    test<signed char>(); +    test<unsigned char>(); +    test<wchar_t>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(); +    test<char32_t>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(); +    test<unsigned short>(); +    test<int>(); +    test<unsigned int>(); +    test<long>(); +    test<unsigned long>(); +    test<long long>(); +    test<unsigned long long>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(); +    test<__uint128_t>(); +#endif +    test<float>(); +    test<double>(); +    test<long double>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp new file mode 100644 index 000000000000..98a2a53d192e --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// radix + +#include <limits> +#include <cfloat> + +template <class T, int expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::radix == expected, "radix test 1"); +    static_assert(std::numeric_limits<const T>::radix == expected, "radix test 2"); +    static_assert(std::numeric_limits<volatile T>::radix == expected, "radix test 3"); +    static_assert(std::numeric_limits<const volatile T>::radix == expected, "radix test 4"); +} + +int main() +{ +    test<bool, 2>(); +    test<char, 2>(); +    test<signed char, 2>(); +    test<unsigned char, 2>(); +    test<wchar_t, 2>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, 2>(); +    test<char32_t, 2>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, 2>(); +    test<unsigned short, 2>(); +    test<int, 2>(); +    test<unsigned int, 2>(); +    test<long, 2>(); +    test<unsigned long, 2>(); +    test<long long, 2>(); +    test<unsigned long long, 2>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, 2>(); +    test<__uint128_t, 2>(); +#endif +    test<float, FLT_RADIX>(); +    test<double, FLT_RADIX>(); +    test<long double, FLT_RADIX>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp new file mode 100644 index 000000000000..5da5c9513a86 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// round_error() + +#include <limits> +#include <cfloat> +#include <cassert> + +template <class T> +void +test(T expected) +{ +    assert(std::numeric_limits<T>::round_error() == expected); +    assert(std::numeric_limits<const T>::round_error() == expected); +    assert(std::numeric_limits<volatile T>::round_error() == expected); +    assert(std::numeric_limits<const volatile T>::round_error() == expected); +} + +int main() +{ +    test<bool>(false); +    test<char>(0); +    test<signed char>(0); +    test<unsigned char>(0); +    test<wchar_t>(0); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(0); +    test<char32_t>(0); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(0); +    test<unsigned short>(0); +    test<int>(0); +    test<unsigned int>(0); +    test<long>(0); +    test<unsigned long>(0); +    test<long long>(0); +    test<unsigned long long>(0); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(0); +    test<__uint128_t>(0); +#endif +    test<float>(0.5); +    test<double>(0.5); +    test<long double>(0.5); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp new file mode 100644 index 000000000000..645f6f7df76a --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// round_style + +#include <limits> + +template <class T, std::float_round_style expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::round_style == expected, "round_style test 1"); +    static_assert(std::numeric_limits<const T>::round_style == expected, "round_style test 2"); +    static_assert(std::numeric_limits<volatile T>::round_style == expected, "round_style test 3"); +    static_assert(std::numeric_limits<const volatile T>::round_style == expected, "round_style test 4"); +} + +int main() +{ +    test<bool, std::round_toward_zero>(); +    test<char, std::round_toward_zero>(); +    test<signed char, std::round_toward_zero>(); +    test<unsigned char, std::round_toward_zero>(); +    test<wchar_t, std::round_toward_zero>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, std::round_toward_zero>(); +    test<char32_t, std::round_toward_zero>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, std::round_toward_zero>(); +    test<unsigned short, std::round_toward_zero>(); +    test<int, std::round_toward_zero>(); +    test<unsigned int, std::round_toward_zero>(); +    test<long, std::round_toward_zero>(); +    test<unsigned long, std::round_toward_zero>(); +    test<long long, std::round_toward_zero>(); +    test<unsigned long long, std::round_toward_zero>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, std::round_toward_zero>(); +    test<__uint128_t, std::round_toward_zero>(); +#endif +    test<float, std::round_to_nearest>(); +    test<double, std::round_to_nearest>(); +    test<long double, std::round_to_nearest>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp new file mode 100644 index 000000000000..d9df999ddb70 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// signaling_NaN() + +#include <limits> +#include <cmath> +#include <type_traits> +#include <cassert> + +template <class T> +void +test_imp(std::true_type) +{ +    assert(std::isnan(std::numeric_limits<T>::signaling_NaN())); +    assert(std::isnan(std::numeric_limits<const T>::signaling_NaN())); +    assert(std::isnan(std::numeric_limits<volatile T>::signaling_NaN())); +    assert(std::isnan(std::numeric_limits<const volatile T>::signaling_NaN())); +} + +template <class T> +void +test_imp(std::false_type) +{ +    assert(std::numeric_limits<T>::signaling_NaN() == T()); +    assert(std::numeric_limits<const T>::signaling_NaN() == T()); +    assert(std::numeric_limits<volatile T>::signaling_NaN() == T()); +    assert(std::numeric_limits<const volatile T>::signaling_NaN() == T()); +} + +template <class T> +inline +void +test() +{ +    test_imp<T>(std::is_floating_point<T>()); +} + +int main() +{ +    test<bool>(); +    test<char>(); +    test<signed char>(); +    test<unsigned char>(); +    test<wchar_t>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t>(); +    test<char32_t>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short>(); +    test<unsigned short>(); +    test<int>(); +    test<unsigned int>(); +    test<long>(); +    test<unsigned long>(); +    test<long long>(); +    test<unsigned long long>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t>(); +    test<__uint128_t>(); +#endif +    test<float>(); +    test<double>(); +    test<long double>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp new file mode 100644 index 000000000000..9e2a8431a4e0 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// tinyness_before + +#include <limits> + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::tinyness_before == expected, "tinyness_before test 1"); +    static_assert(std::numeric_limits<const T>::tinyness_before == expected, "tinyness_before test 2"); +    static_assert(std::numeric_limits<volatile T>::tinyness_before == expected, "tinyness_before test 3"); +    static_assert(std::numeric_limits<const volatile T>::tinyness_before == expected, "tinyness_before test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, false>(); +    test<signed char, false>(); +    test<unsigned char, false>(); +    test<wchar_t, false>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, false>(); +    test<char32_t, false>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, false>(); +    test<unsigned short, false>(); +    test<int, false>(); +    test<unsigned int, false>(); +    test<long, false>(); +    test<unsigned long, false>(); +    test<long long, false>(); +    test<unsigned long long, false>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, false>(); +    test<__uint128_t, false>(); +#endif +    test<float, false>(); +    test<double, false>(); +    test<long double, false>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp new file mode 100644 index 000000000000..af93e78c0e91 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +//                     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 numeric_limits + +// traps + +#include <limits> + +#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) +static const bool integral_types_trap = true; +#else +static const bool integral_types_trap = false; +#endif + +template <class T, bool expected> +void +test() +{ +    static_assert(std::numeric_limits<T>::traps == expected, "traps test 1"); +    static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2"); +    static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3"); +    static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4"); +} + +int main() +{ +    test<bool, false>(); +    test<char, integral_types_trap>(); +    test<signed char, integral_types_trap>(); +    test<unsigned char, integral_types_trap>(); +    test<wchar_t, integral_types_trap>(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +    test<char16_t, integral_types_trap>(); +    test<char32_t, integral_types_trap>(); +#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS +    test<short, integral_types_trap>(); +    test<unsigned short, integral_types_trap>(); +    test<int, integral_types_trap>(); +    test<unsigned int, integral_types_trap>(); +    test<long, integral_types_trap>(); +    test<unsigned long, integral_types_trap>(); +    test<long long, integral_types_trap>(); +    test<unsigned long long, integral_types_trap>(); +#ifndef _LIBCPP_HAS_NO_INT128 +    test<__int128_t, integral_types_trap>(); +    test<__uint128_t, integral_types_trap>(); +#endif +    test<float, false>(); +    test<double, false>(); +    test<long double, false>(); +} diff --git a/test/std/language.support/support.limits/limits/numeric.limits/default.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits/default.pass.cpp new file mode 100644 index 000000000000..6cf5681d82ba --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.limits/default.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. +// +//===----------------------------------------------------------------------===// + +// test numeric_limits + +// The default numeric_limits<T> template shall have all members, but with +// 0 or false values. + +#include <limits> +#include <cassert> + +struct A +{ +    A(int i = 0) : data_(i) {} +    int data_; +}; + +bool operator == (const A& x, const A& y) {return x.data_ == y.data_;} + +int main() +{ +    static_assert(std::numeric_limits<A>::is_specialized == false, +                 "std::numeric_limits<A>::is_specialized == false"); +    assert(std::numeric_limits<A>::min() == A()); +    assert(std::numeric_limits<A>::max() == A()); +    assert(std::numeric_limits<A>::lowest() == A()); +    static_assert(std::numeric_limits<A>::digits == 0, +                 "std::numeric_limits<A>::digits == 0"); +    static_assert(std::numeric_limits<A>::digits10 == 0, +                 "std::numeric_limits<A>::digits10 == 0"); +    static_assert(std::numeric_limits<A>::max_digits10 == 0, +                 "std::numeric_limits<A>::max_digits10 == 0"); +    static_assert(std::numeric_limits<A>::is_signed == false, +                 "std::numeric_limits<A>::is_signed == false"); +    static_assert(std::numeric_limits<A>::is_integer == false, +                 "std::numeric_limits<A>::is_integer == false"); +    static_assert(std::numeric_limits<A>::is_exact == false, +                 "std::numeric_limits<A>::is_exact == false"); +    static_assert(std::numeric_limits<A>::radix == 0, +                 "std::numeric_limits<A>::radix == 0"); +    assert(std::numeric_limits<A>::epsilon() == A()); +    assert(std::numeric_limits<A>::round_error() == A()); +    static_assert(std::numeric_limits<A>::min_exponent == 0, +                 "std::numeric_limits<A>::min_exponent == 0"); +    static_assert(std::numeric_limits<A>::min_exponent10 == 0, +                 "std::numeric_limits<A>::min_exponent10 == 0"); +    static_assert(std::numeric_limits<A>::max_exponent == 0, +                 "std::numeric_limits<A>::max_exponent == 0"); +    static_assert(std::numeric_limits<A>::max_exponent10 == 0, +                 "std::numeric_limits<A>::max_exponent10 == 0"); +    static_assert(std::numeric_limits<A>::has_infinity == false, +                 "std::numeric_limits<A>::has_infinity == false"); +    static_assert(std::numeric_limits<A>::has_quiet_NaN == false, +                 "std::numeric_limits<A>::has_quiet_NaN == false"); +    static_assert(std::numeric_limits<A>::has_signaling_NaN == false, +                 "std::numeric_limits<A>::has_signaling_NaN == false"); +    static_assert(std::numeric_limits<A>::has_denorm == std::denorm_absent, +                 "std::numeric_limits<A>::has_denorm == std::denorm_absent"); +    static_assert(std::numeric_limits<A>::has_denorm_loss == false, +                 "std::numeric_limits<A>::has_denorm_loss == false"); +    assert(std::numeric_limits<A>::infinity() == A()); +    assert(std::numeric_limits<A>::quiet_NaN() == A()); +    assert(std::numeric_limits<A>::signaling_NaN() == A()); +    assert(std::numeric_limits<A>::denorm_min() == A()); +    static_assert(std::numeric_limits<A>::is_iec559 == false, +                 "std::numeric_limits<A>::is_iec559 == false"); +    static_assert(std::numeric_limits<A>::is_bounded == false, +                 "std::numeric_limits<A>::is_bounded == false"); +    static_assert(std::numeric_limits<A>::is_modulo == false, +                 "std::numeric_limits<A>::is_modulo == false"); +    static_assert(std::numeric_limits<A>::traps == false, +                 "std::numeric_limits<A>::traps == false"); +    static_assert(std::numeric_limits<A>::tinyness_before == false, +                 "std::numeric_limits<A>::tinyness_before == false"); +    static_assert(std::numeric_limits<A>::round_style == std::round_toward_zero, +                 "std::numeric_limits<A>::round_style == std::round_toward_zero"); +} diff --git a/test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp b/test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/language.support/support.limits/limits/round.style/check_values.pass.cpp b/test/std/language.support/support.limits/limits/round.style/check_values.pass.cpp new file mode 100644 index 000000000000..d6c70c4cf230 --- /dev/null +++ b/test/std/language.support/support.limits/limits/round.style/check_values.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. +// +//===----------------------------------------------------------------------===// + +// test numeric_limits + +// float_denorm_style + +#include <limits> + +typedef char one; +struct two {one _[2];}; + +one test(std::float_denorm_style); +two test(int); + +int main() +{ +    static_assert(std::denorm_indeterminate == -1, +                 "std::denorm_indeterminate == -1"); +    static_assert(std::denorm_absent == 0, +                 "std::denorm_absent == 0"); +    static_assert(std::denorm_present == 1, +                 "std::denorm_present == 1"); +    static_assert(sizeof(test(std::denorm_present)) == 1, +                 "sizeof(test(std::denorm_present)) == 1"); +    static_assert(sizeof(test(1)) == 2, +                 "sizeof(test(1)) == 2"); +} diff --git a/test/std/language.support/support.limits/limits/version.pass.cpp b/test/std/language.support/support.limits/limits/version.pass.cpp new file mode 100644 index 000000000000..0cb3f6f52a4e --- /dev/null +++ b/test/std/language.support/support.limits/limits/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <limits> + +#include <limits> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.limits/nothing_to_do.pass.cpp b/test/std/language.support/support.limits/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..b58f5c55b643 --- /dev/null +++ b/test/std/language.support/support.limits/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp b/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp new file mode 100644 index 000000000000..448ffba2c2bd --- /dev/null +++ b/test/std/language.support/support.rtti/bad.cast/bad_cast.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +//                     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 bad_cast + +#include <typeinfo> +#include <type_traits> +#include <cassert> + +int main() +{ +    static_assert((std::is_base_of<std::exception, std::bad_cast>::value), +                 "std::is_base_of<std::exception, std::bad_cast>::value"); +    static_assert(std::is_polymorphic<std::bad_cast>::value, +                 "std::is_polymorphic<std::bad_cast>::value"); +    std::bad_cast b; +    std::bad_cast b2 = b; +    b2 = b; +    const char* w = b2.what(); +    assert(w); +} diff --git a/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp b/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp new file mode 100644 index 000000000000..190aebe54970 --- /dev/null +++ b/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +//                     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 bad_typeid + +#include <typeinfo> +#include <type_traits> +#include <cassert> + +int main() +{ +    static_assert((std::is_base_of<std::exception, std::bad_typeid>::value), +                 "std::is_base_of<std::exception, std::bad_typeid>::value"); +    static_assert(std::is_polymorphic<std::bad_typeid>::value, +                 "std::is_polymorphic<std::bad_typeid>::value"); +    std::bad_typeid b; +    std::bad_typeid b2 = b; +    b2 = b; +    const char* w = b2.what(); +    assert(w); +} diff --git a/test/std/language.support/support.rtti/type.info/type_info.pass.cpp b/test/std/language.support/support.rtti/type.info/type_info.pass.cpp new file mode 100644 index 000000000000..2616865e6da9 --- /dev/null +++ b/test/std/language.support/support.rtti/type.info/type_info.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +//                     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 type_info + +#include <typeinfo> +#include <cstring> +#include <cassert> + +int main() +{ +    const std::type_info& t1 = typeid(int); +    const std::type_info& t2 = typeid(int); +    assert(t1 == t2); +    const std::type_info& t3 = typeid(short); +    assert(t1 != t3); +    assert(!t1.before(t2)); +    assert(strcmp(t1.name(), t2.name()) == 0); +    assert(strcmp(t1.name(), t3.name()) != 0); +} diff --git a/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp b/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp new file mode 100644 index 000000000000..c91a21ff2dae --- /dev/null +++ b/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +//                     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 type_info + +#include <typeinfo> +#include <cstring> +#include <cassert> + +int main() +{ +    const std::type_info& t1 = typeid(int); +    const std::type_info& t2 = typeid(int); +    const std::type_info& t3 = typeid(short); +    assert(t1.hash_code() == t2.hash_code()); +    assert(t1.hash_code() != t3.hash_code()); +} diff --git a/test/std/language.support/support.rtti/version.pass.cpp b/test/std/language.support/support.rtti/version.pass.cpp new file mode 100644 index 000000000000..0a9ece34f97e --- /dev/null +++ b/test/std/language.support/support.rtti/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <typeinfo> + +#include <typeinfo> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.runtime/csetjmp.pass.cpp b/test/std/language.support/support.runtime/csetjmp.pass.cpp new file mode 100644 index 000000000000..dc034ce099e2 --- /dev/null +++ b/test/std/language.support/support.runtime/csetjmp.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +//                     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 <csetjmp> + +#include <csetjmp> +#include <type_traits> + +#ifndef setjmp +#error setjmp not defined +#endif + +int main() +{ +    std::jmp_buf jb; +    static_assert((std::is_same<decltype(std::longjmp(jb, 0)), void>::value), +                  "std::is_same<decltype(std::longjmp(jb, 0)), void>::value"); +} diff --git a/test/std/language.support/support.runtime/csignal.pass.cpp b/test/std/language.support/support.runtime/csignal.pass.cpp new file mode 100644 index 000000000000..717347df7f00 --- /dev/null +++ b/test/std/language.support/support.runtime/csignal.pass.cpp @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +//                     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 <csignal> + +#include <csignal> +#include <type_traits> + +#ifndef SIG_DFL +#error SIG_DFL not defined +#endif + +#ifndef SIG_ERR +#error SIG_ERR not defined +#endif + +#ifndef SIG_IGN +#error SIG_IGN not defined +#endif + +#ifndef SIGABRT +#error SIGABRT not defined +#endif + +#ifndef SIGFPE +#error SIGFPE not defined +#endif + +#ifndef SIGILL +#error SIGILL not defined +#endif + +#ifndef SIGINT +#error SIGINT not defined +#endif + +#ifndef SIGSEGV +#error SIGSEGV not defined +#endif + +#ifndef SIGTERM +#error SIGTERM not defined +#endif + +int main() +{ +    std::sig_atomic_t sig; +    typedef void (*func)(int); +    static_assert((std::is_same<decltype(std::signal(0, (func)0)), func>::value), ""); +    static_assert((std::is_same<decltype(std::raise(0)), int>::value), ""); +} diff --git a/test/std/language.support/support.runtime/cstdarg.pass.cpp b/test/std/language.support/support.runtime/cstdarg.pass.cpp new file mode 100644 index 000000000000..059ad2f4ff91 --- /dev/null +++ b/test/std/language.support/support.runtime/cstdarg.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +//                     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 <cstdarg> + +#include <cstdarg> + +#ifndef va_arg +#error va_arg not defined +#endif + +#if __cplusplus >= 201103L +#  ifndef va_copy +#    error va_copy is not defined when c++ >= 11 +#  endif +#endif + +#ifndef va_end +#error va_end not defined +#endif + +#ifndef va_start +#error va_start not defined +#endif + +int main() +{ +    std::va_list va; +} diff --git a/test/std/language.support/support.runtime/cstdbool.pass.cpp b/test/std/language.support/support.runtime/cstdbool.pass.cpp new file mode 100644 index 000000000000..f52c1556feb0 --- /dev/null +++ b/test/std/language.support/support.runtime/cstdbool.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +//                     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 <cstdbool> + +#include <cstdbool> + +#ifndef __bool_true_false_are_defined +#error __bool_true_false_are_defined not defined +#endif + +#ifdef bool +#error bool should not be defined +#endif + +#ifdef true +#error true should not be defined +#endif + +#ifdef false +#error false should not be defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.runtime/cstdlib.pass.cpp b/test/std/language.support/support.runtime/cstdlib.pass.cpp new file mode 100644 index 000000000000..073949122b01 --- /dev/null +++ b/test/std/language.support/support.runtime/cstdlib.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +//                     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 <cstdlib> + +#include <cstdlib> +#include <type_traits> + +#ifndef EXIT_FAILURE +#error EXIT_FAILURE not defined +#endif + +#ifndef EXIT_SUCCESS +#error EXIT_SUCCESS not defined +#endif + +#ifndef MB_CUR_MAX +#error MB_CUR_MAX not defined +#endif + +#ifndef NULL +#error NULL not defined +#endif + +#ifndef RAND_MAX +#error RAND_MAX not defined +#endif + +int main() +{ +    std::size_t s = 0; +    std::div_t d; +    std::ldiv_t ld; +    std::lldiv_t lld; +    char** endptr = 0; +    static_assert((std::is_same<decltype(std::atof("")), double>::value), ""); +    static_assert((std::is_same<decltype(std::atoi("")), int>::value), ""); +    static_assert((std::is_same<decltype(std::atol("")), long>::value), ""); +    static_assert((std::is_same<decltype(std::atoll("")), long long>::value), ""); +    static_assert((std::is_same<decltype(std::getenv("")), char*>::value), ""); +    static_assert((std::is_same<decltype(std::strtod("", endptr)), double>::value), ""); +    static_assert((std::is_same<decltype(std::strtof("", endptr)), float>::value), ""); +    static_assert((std::is_same<decltype(std::strtold("", endptr)), long double>::value), ""); +    static_assert((std::is_same<decltype(std::strtol("", endptr,0)), long>::value), ""); +    static_assert((std::is_same<decltype(std::strtoll("", endptr,0)), long long>::value), ""); +    static_assert((std::is_same<decltype(std::strtoul("", endptr,0)), unsigned long>::value), ""); +    static_assert((std::is_same<decltype(std::strtoull("", endptr,0)), unsigned long long>::value), ""); +    static_assert((std::is_same<decltype(std::rand()), int>::value), ""); +    static_assert((std::is_same<decltype(std::srand(0)), void>::value), ""); +    static_assert((std::is_same<decltype(std::calloc(0,0)), void*>::value), ""); +    static_assert((std::is_same<decltype(std::free(0)), void>::value), ""); +    static_assert((std::is_same<decltype(std::malloc(0)), void*>::value), ""); +    static_assert((std::is_same<decltype(std::realloc(0,0)), void*>::value), ""); +    static_assert((std::is_same<decltype(std::abort()), void>::value), ""); +    static_assert((std::is_same<decltype(std::atexit(0)), int>::value), ""); +    static_assert((std::is_same<decltype(std::exit(0)), void>::value), ""); +    static_assert((std::is_same<decltype(std::_Exit(0)), void>::value), ""); +    static_assert((std::is_same<decltype(std::getenv("")), char*>::value), ""); +    static_assert((std::is_same<decltype(std::system("")), int>::value), ""); +    static_assert((std::is_same<decltype(std::bsearch(0,0,0,0,0)), void*>::value), ""); +    static_assert((std::is_same<decltype(std::qsort(0,0,0,0)), void>::value), ""); +    static_assert((std::is_same<decltype(std::abs(0)), int>::value), ""); +    static_assert((std::is_same<decltype(std::abs((long)0)), long>::value), ""); +    static_assert((std::is_same<decltype(std::abs((long long)0)), long long>::value), ""); +    static_assert((std::is_same<decltype(std::labs((long)0)), long>::value), ""); +    static_assert((std::is_same<decltype(std::llabs((long long)0)), long long>::value), ""); +    static_assert((std::is_same<decltype(std::div(0,0)), std::div_t>::value), ""); +    static_assert((std::is_same<decltype(std::div(0L,0L)), std::ldiv_t>::value), ""); +    static_assert((std::is_same<decltype(std::div(0LL,0LL)), std::lldiv_t>::value), ""); +    static_assert((std::is_same<decltype(std::ldiv(0L,0L)), std::ldiv_t>::value), ""); +    static_assert((std::is_same<decltype(std::lldiv(0LL,0LL)), std::lldiv_t>::value), ""); +    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.runtime/ctime.pass.cpp b/test/std/language.support/support.runtime/ctime.pass.cpp new file mode 100644 index 000000000000..8c5d2811d8a9 --- /dev/null +++ b/test/std/language.support/support.runtime/ctime.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +//                     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 <ctime> + +#include <ctime> +#include <type_traits> + +#ifndef NULL +#error NULL not defined +#endif + +#ifndef CLOCKS_PER_SEC +#error CLOCKS_PER_SEC not defined +#endif + +int main() +{ +    std::clock_t c = 0; +    std::size_t s = 0; +    std::time_t t = 0; +    std::tm tm = {0}; +    static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), ""); +    static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), ""); +    static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), ""); +    static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), ""); +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS +    static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), ""); +    static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), ""); +    static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), ""); +    static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), ""); +#endif +    char* c1 = 0; +    const char* c2 = 0; +    static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), ""); +} diff --git a/test/std/language.support/support.runtime/version_csetjmp.pass.cpp b/test/std/language.support/support.runtime/version_csetjmp.pass.cpp new file mode 100644 index 000000000000..7e37716d0145 --- /dev/null +++ b/test/std/language.support/support.runtime/version_csetjmp.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <csetjmp> + +#include <csetjmp> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.runtime/version_csignal.pass.cpp b/test/std/language.support/support.runtime/version_csignal.pass.cpp new file mode 100644 index 000000000000..be1045f1eb3b --- /dev/null +++ b/test/std/language.support/support.runtime/version_csignal.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <csignal> + +#include <csignal> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.runtime/version_cstdarg.pass.cpp b/test/std/language.support/support.runtime/version_cstdarg.pass.cpp new file mode 100644 index 000000000000..f3ca9389b15d --- /dev/null +++ b/test/std/language.support/support.runtime/version_cstdarg.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <cstdarg> + +#include <cstdarg> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.runtime/version_cstdbool.pass.cpp b/test/std/language.support/support.runtime/version_cstdbool.pass.cpp new file mode 100644 index 000000000000..0415227e58ea --- /dev/null +++ b/test/std/language.support/support.runtime/version_cstdbool.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <cstdbool> + +#include <cstdbool> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.runtime/version_cstdlib.pass.cpp b/test/std/language.support/support.runtime/version_cstdlib.pass.cpp new file mode 100644 index 000000000000..db419524f578 --- /dev/null +++ b/test/std/language.support/support.runtime/version_cstdlib.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <cstdlib> + +#include <cstdlib> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.runtime/version_ctime.pass.cpp b/test/std/language.support/support.runtime/version_ctime.pass.cpp new file mode 100644 index 000000000000..ce0bf2cf1853 --- /dev/null +++ b/test/std/language.support/support.runtime/version_ctime.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <ctime> + +#include <ctime> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.start.term/quick_exit.pass.cpp b/test/std/language.support/support.start.term/quick_exit.pass.cpp new file mode 100644 index 000000000000..bcfdbb75402e --- /dev/null +++ b/test/std/language.support/support.start.term/quick_exit.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +//                     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 quick_exit and at_quick_exit + +#include <cstdlib> + +void f() {} + +int main() +{ +#ifdef _LIBCPP_HAS_QUICK_EXIT +    std::at_quick_exit(f); +    std::quick_exit(0); +#endif +} diff --git a/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp b/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp new file mode 100644 index 000000000000..8b9729379163 --- /dev/null +++ b/test/std/language.support/support.start.term/quick_exit_check1.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +//                     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 that referencing at_quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined +// results in a compile error. + +#include <cstdlib> + +void f() {} + +int main() +{ +#ifndef _LIBCPP_HAS_QUICK_EXIT +    std::at_quick_exit(f); +#else +#error +#endif +} diff --git a/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp b/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp new file mode 100644 index 000000000000..395914136820 --- /dev/null +++ b/test/std/language.support/support.start.term/quick_exit_check2.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +//                     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 that referencing quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined +// results in a compile error. + +#include <cstdlib> + +void f() {} + +int main() +{ +#ifndef _LIBCPP_HAS_QUICK_EXIT +    std::quick_exit(0); +#else +#error +#endif +} diff --git a/test/std/language.support/support.types/max_align_t.pass.cpp b/test/std/language.support/support.types/max_align_t.pass.cpp new file mode 100644 index 000000000000..08a6c28a4c19 --- /dev/null +++ b/test/std/language.support/support.types/max_align_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. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <type_traits> + +// max_align_t is a POD type whose alignment requirement is at least as +//   great as that of every scalar type + +#include <stdio.h> + +int main() +{ +    static_assert(std::is_pod<std::max_align_t>::value, +                  "std::is_pod<std::max_align_t>::value"); +    static_assert((std::alignment_of<std::max_align_t>::value >= +                  std::alignment_of<long long>::value), +                  "std::alignment_of<std::max_align_t>::value >= " +                  "std::alignment_of<long long>::value"); +    static_assert(std::alignment_of<std::max_align_t>::value >= +                  std::alignment_of<long double>::value, +                  "std::alignment_of<std::max_align_t>::value >= " +                  "std::alignment_of<long double>::value"); +    static_assert(std::alignment_of<std::max_align_t>::value >= +                  std::alignment_of<void*>::value, +                  "std::alignment_of<std::max_align_t>::value >= " +                  "std::alignment_of<void*>::value"); +} diff --git a/test/std/language.support/support.types/null.pass.cpp b/test/std/language.support/support.types/null.pass.cpp new file mode 100644 index 000000000000..7e31a8525c00 --- /dev/null +++ b/test/std/language.support/support.types/null.pass.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> + +#ifndef NULL +#error NULL not defined +#endif + +int main() +{ +} diff --git a/test/std/language.support/support.types/nullptr_t.pass.cpp b/test/std/language.support/support.types/nullptr_t.pass.cpp new file mode 100644 index 000000000000..4d7c8b0bc0a6 --- /dev/null +++ b/test/std/language.support/support.types/nullptr_t.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <type_traits> +#include <cassert> + +// typedef decltype(nullptr) nullptr_t; + +struct A +{ +    A(std::nullptr_t) {} +}; + +template <class T> +void test_conversions() +{ +    { +        T p = 0; +        assert(p == nullptr); +    } +    { +        T p = nullptr; +        assert(p == nullptr); +        assert(nullptr == p); +        assert(!(p != nullptr)); +        assert(!(nullptr != p)); +    } +} + +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)); +} + + +int main() +{ +    static_assert(sizeof(std::nullptr_t) == sizeof(void*), +                  "sizeof(std::nullptr_t) == sizeof(void*)"); + +    { +        test_conversions<std::nullptr_t>(); +        test_conversions<void*>(); +        test_conversions<A*>(); +        test_conversions<void(*)()>(); +        test_conversions<void(A::*)()>(); +        test_conversions<int A::*>(); +    } +    { +        test_comparisons<std::nullptr_t>(); +        test_comparisons<void*>(); +        test_comparisons<A*>(); +        test_comparisons<void(*)()>(); +    } +    { +        bool b = nullptr; +        assert(!b); +    } +} diff --git a/test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp b/test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp new file mode 100644 index 000000000000..92bd87943e12 --- /dev/null +++ b/test/std/language.support/support.types/nullptr_t_integral_cast.fail.cpp @@ -0,0 +1,17 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// typedef decltype(nullptr) nullptr_t; + +#include <cstddef> + +int main() +{ +    std::ptrdiff_t i = static_cast<std::ptrdiff_t>(nullptr); +} diff --git a/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp b/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp new file mode 100644 index 000000000000..34c7a93e41c5 --- /dev/null +++ b/test/std/language.support/support.types/nullptr_t_integral_cast.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// NOTE: nullptr_t emulation cannot handle a reinterpret_cast to an +// integral type +// XFAIL: c++98, c++03 + +// typedef decltype(nullptr) nullptr_t; + + +#include <cstddef> +#include <cassert> + +int main() +{ +    std::ptrdiff_t i = reinterpret_cast<std::ptrdiff_t>(nullptr); +    assert(i == 0); +} diff --git a/test/std/language.support/support.types/offsetof.pass.cpp b/test/std/language.support/support.types/offsetof.pass.cpp new file mode 100644 index 000000000000..e36ac22974ff --- /dev/null +++ b/test/std/language.support/support.types/offsetof.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> + +#ifndef offsetof +#error offsetof not defined +#endif + +struct A +{ +    int x; +}; + +int main() +{ +#if (__has_feature(cxx_noexcept)) +    static_assert(noexcept(offsetof(A, x)), ""); +#endif +} diff --git a/test/std/language.support/support.types/ptrdiff_t.pass.cpp b/test/std/language.support/support.types/ptrdiff_t.pass.cpp new file mode 100644 index 000000000000..702ec720a913 --- /dev/null +++ b/test/std/language.support/support.types/ptrdiff_t.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <type_traits> + +// ptrdiff_t should: + +//  1. be in namespace std. +//  2. be the same sizeof as void*. +//  3. be a signed integral. + +int main() +{ +    static_assert(sizeof(std::ptrdiff_t) == sizeof(void*), +                  "sizeof(std::ptrdiff_t) == sizeof(void*)"); +    static_assert(std::is_signed<std::ptrdiff_t>::value, +                  "std::is_signed<std::ptrdiff_t>::value"); +    static_assert(std::is_integral<std::ptrdiff_t>::value, +                  "std::is_integral<std::ptrdiff_t>::value"); +} diff --git a/test/std/language.support/support.types/size_t.pass.cpp b/test/std/language.support/support.types/size_t.pass.cpp new file mode 100644 index 000000000000..bb3b0805b5ad --- /dev/null +++ b/test/std/language.support/support.types/size_t.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +#include <cstddef> +#include <type_traits> + +// size_t should: + +//  1. be in namespace std. +//  2. be the same sizeof as void*. +//  3. be an unsigned integral. + +int main() +{ +    static_assert(sizeof(std::size_t) == sizeof(void*), +                  "sizeof(std::size_t) == sizeof(void*)"); +    static_assert(std::is_unsigned<std::size_t>::value, +                  "std::is_unsigned<std::size_t>::value"); +    static_assert(std::is_integral<std::size_t>::value, +                  "std::is_integral<std::size_t>::value"); +} diff --git a/test/std/language.support/support.types/version.pass.cpp b/test/std/language.support/support.types/version.pass.cpp new file mode 100644 index 000000000000..2ab7c188de1d --- /dev/null +++ b/test/std/language.support/support.types/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +//                     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. +// +//===----------------------------------------------------------------------===// + +// <cstddef> + +#include <cstddef> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +}  | 
