From owner-svn-src-all@freebsd.org Sat Jun 10 13:44:44 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20E6FB954CF; Sat, 10 Jun 2017 13:44:44 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB11578A53; Sat, 10 Jun 2017 13:44:43 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5ADihYu094958; Sat, 10 Jun 2017 13:44:43 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5ADifoO094939; Sat, 10 Jun 2017 13:44:41 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201706101344.v5ADifoO094939@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 10 Jun 2017 13:44:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r319786 - in vendor/libc++/dist: include test/libcxx/utilities/variant/variant.variant/variant.assign test/libcxx/utilities/variant/variant.variant/variant.ctor test/std/localization/lo... X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jun 2017 13:44:44 -0000 Author: dim Date: Sat Jun 10 13:44:41 2017 New Revision: 319786 URL: https://svnweb.freebsd.org/changeset/base/319786 Log: Vendor import of libc++ trunk r305145: https://llvm.org/svn/llvm-project/libcxx/trunk@305145 Added: vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/ vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp (contents, props changed) vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp (contents, props changed) vendor/libc++/dist/test/std/numerics/numeric.ops/transform.exclusive.scan/ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp (contents, props changed) vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/implicit_deduction_guides.pass.cpp (contents, props changed) Deleted: vendor/libc++/dist/test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp vendor/libc++/dist/test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp vendor/libc++/dist/test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp vendor/libc++/dist/test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp vendor/libc++/dist/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp Modified: vendor/libc++/dist/include/__mutex_base vendor/libc++/dist/include/mutex vendor/libc++/dist/include/numeric vendor/libc++/dist/include/optional vendor/libc++/dist/include/tuple vendor/libc++/dist/include/variant vendor/libc++/dist/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp vendor/libc++/dist/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp vendor/libc++/dist/test/support/msvc_stdlib_force_include.hpp vendor/libc++/dist/test/support/platform_support.h vendor/libc++/dist/test/support/test_workarounds.h vendor/libc++/dist/test/support/uses_alloc_types.hpp vendor/libc++/dist/test/support/variant_test_helpers.hpp vendor/libc++/dist/www/cxx1z_status.html Modified: vendor/libc++/dist/include/__mutex_base ============================================================================== --- vendor/libc++/dist/include/__mutex_base Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/include/__mutex_base Sat Jun 10 13:44:41 2017 (r319786) @@ -48,7 +48,7 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATIO public: _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_CXX03_LANG - constexpr mutex() _NOEXCEPT = default; + constexpr mutex() = default; #else mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} #endif @@ -66,6 +66,9 @@ class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATIO typedef __libcpp_mutex_t* native_handle_type; _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;} }; + +static_assert(is_nothrow_default_constructible::value, + "the default constructor for std::mutex must be nothrow"); struct _LIBCPP_TYPE_VIS defer_lock_t {}; struct _LIBCPP_TYPE_VIS try_to_lock_t {}; Modified: vendor/libc++/dist/include/mutex ============================================================================== --- vendor/libc++/dist/include/mutex Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/include/mutex Sat Jun 10 13:44:41 2017 (r319786) @@ -502,7 +502,6 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock<_Mutex> { (publ _LIBCPP_INLINE_VISIBILITY explicit scoped_lock(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) : __m_(__m) {} - scoped_lock(scoped_lock const&) = delete; scoped_lock& operator=(scoped_lock const&) = delete; Modified: vendor/libc++/dist/include/numeric ============================================================================== --- vendor/libc++/dist/include/numeric Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/include/numeric Sat Jun 10 13:44:41 2017 (r319786) @@ -42,6 +42,23 @@ template + OutputIterator + exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init); // C++17 + +template + OutputIterator + exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, BinaryOperation binary_op); // C++17 + +template + OutputIterator + transform_exclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, T init, + BinaryOperation binary_op, UnaryOperation unary_op); // C++17 + template OutputIterator adjacent_difference(InputIterator first, InputIterator last, OutputIterator result); @@ -66,6 +83,7 @@ template #include <__config> #include #include // for numeric_limits +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -153,6 +171,59 @@ partial_sum(_InputIterator __first, _InputIterator __l } return __result; } + +#if _LIBCPP_STD_VER > 14 +template +inline _LIBCPP_INLINE_VISIBILITY +_OutputIterator +exclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp __init, _BinaryOp __b) +{ + if (__first != __last) + { + _Tp __saved = __init; + do + { + __init = __b(__init, *__first); + *__result = __saved; + __saved = __init; + ++__result; + } while (++__first != __last); + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_OutputIterator +exclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp __init) +{ + return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>()); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_OutputIterator +transform_exclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Tp __init, + _BinaryOp __b, _UnaryOp __u) +{ + if (__first != __last) + { + _Tp __saved = __init; + do + { + __init = __b(__init, __u(*__first)); + *__result = __saved; + __saved = __init; + ++__result; + } while (++__first != __last); + } + return __result; +} +#endif template inline _LIBCPP_INLINE_VISIBILITY Modified: vendor/libc++/dist/include/optional ============================================================================== --- vendor/libc++/dist/include/optional Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/include/optional Sat Jun 10 13:44:41 2017 (r319786) @@ -897,7 +897,7 @@ class optional (public) template _LIBCPP_INLINE_VISIBILITY - value_type value_or(_Up&& __v) && + constexpr value_type value_or(_Up&& __v) && { static_assert(is_move_constructible_v, "optional::value_or: T must be move constructible"); Modified: vendor/libc++/dist/include/tuple ============================================================================== --- vendor/libc++/dist/include/tuple Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/include/tuple Sat Jun 10 13:44:41 2017 (r319786) @@ -929,6 +929,16 @@ class _LIBCPP_TEMPLATE_VIS tuple<> (public) void swap(tuple&) _NOEXCEPT {} }; +#ifdef __cpp_deduction_guides +// NOTE: These are not yet standardized, but are required to simulate the +// implicit deduction guide that should be generated had libc++ declared the +// tuple-like constructors "correctly" +template +tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>; +template +tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>; +#endif + template inline _LIBCPP_INLINE_VISIBILITY typename enable_if Modified: vendor/libc++/dist/include/variant ============================================================================== --- vendor/libc++/dist/include/variant Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/include/variant Sat Jun 10 13:44:41 2017 (r319786) @@ -358,7 +358,6 @@ struct __traits { static constexpr _Trait __copy_assignable_trait = __common_trait( {__copy_constructible_trait, - __move_constructible_trait, __trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...}); static constexpr _Trait __move_assignable_trait = __common_trait( @@ -877,25 +876,24 @@ class _LIBCPP_TEMPLATE_VIS __assignment : public __cop } protected: - template + template inline _LIBCPP_INLINE_VISIBILITY - void __assign_alt(__alt<_Ip, _Tp>& __a, - _Arg&& __arg, - bool_constant<_CopyAssign> __tag) { + void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) { if (this->index() == _Ip) { __a.__value = _VSTD::forward<_Arg>(__arg); } else { struct { void operator()(true_type) const { - __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg))); + __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg)); } void operator()(false_type) const { - __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg)); + __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg))); } __assignment* __this; _Arg&& __arg; } __impl{this, _VSTD::forward<_Arg>(__arg)}; - __impl(__tag); + __impl(bool_constant || + !is_nothrow_move_constructible_v<_Tp>>{}); } } @@ -912,8 +910,7 @@ class _LIBCPP_TEMPLATE_VIS __assignment : public __cop [this](auto& __this_alt, auto&& __that_alt) { this->__assign_alt( __this_alt, - _VSTD::forward(__that_alt).__value, - is_lvalue_reference<_That>{}); + _VSTD::forward(__that_alt).__value); }, *this, _VSTD::forward<_That>(__that)); } @@ -1013,8 +1010,7 @@ class _LIBCPP_TEMPLATE_VIS __impl (public) inline _LIBCPP_INLINE_VISIBILITY void __assign(_Arg&& __arg) { this->__assign_alt(__access::__base::__get_alt<_Ip>(*this), - _VSTD::forward<_Arg>(__arg), - false_type{}); + _VSTD::forward<_Arg>(__arg)); } inline _LIBCPP_INLINE_VISIBILITY @@ -1088,7 +1084,6 @@ class _LIBCPP_TEMPLATE_VIS variant __all...>::value>, private __sfinae_assign_base< __all<(is_copy_constructible_v<_Types> && - is_move_constructible_v<_Types> && is_copy_assignable_v<_Types>)...>::value, __all<(is_move_constructible_v<_Types> && is_move_assignable_v<_Types>)...>::value> { Modified: vendor/libc++/dist/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -17,6 +17,8 @@ #include #include +#include "platform_support.h" + typedef std::codecvt_byname F; class my_facet @@ -38,12 +40,12 @@ int my_facet::count = 0; int main() { { - std::locale l(std::locale::classic(), new my_facet("en_US")); + std::locale l(std::locale::classic(), new my_facet(LOCALE_en_US)); assert(my_facet::count == 1); } assert(my_facet::count == 0); { - my_facet f("en_US", 1); + my_facet f(LOCALE_en_US, 1); assert(my_facet::count == 1); { std::locale l(std::locale::classic(), &f); @@ -53,12 +55,12 @@ int main() } assert(my_facet::count == 0); { - std::locale l(std::locale::classic(), new my_facet(std::string("en_US"))); + std::locale l(std::locale::classic(), new my_facet(std::string(LOCALE_en_US))); assert(my_facet::count == 1); } assert(my_facet::count == 0); { - my_facet f(std::string("en_US"), 1); + my_facet f(std::string(LOCALE_en_US), 1); assert(my_facet::count == 1); { std::locale l(std::locale::classic(), &f); Added: vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator exclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, T init); +// + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; + +// Not in place + std::exclusive_scan(first, last, std::back_inserter(v), init); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// In place + v.clear(); + v.assign(first, last); + std::exclusive_scan(v.begin(), v.end(), v.begin(), init); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = {1, 3, 5, 7, 9}; + const int pRes[] = {0, 1, 4, 9, 16}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) + test(Iter(ia), Iter(ia + i), 0, pRes, pRes + i); +} + +int triangle(int n) { return n*(n+1)/2; } + +// Basic sanity +void basic_tests() +{ + { + std::vector v(10); + std::fill(v.begin(), v.end(), 3); + std::exclusive_scan(v.begin(), v.end(), v.begin(), 50); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 50 + (int) i * 3); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 0); + std::exclusive_scan(v.begin(), v.end(), v.begin(), 30); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 30 + triangle(i-1)); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::exclusive_scan(v.begin(), v.end(), v.begin(), 40); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 40 + triangle(i)); + } + +} + +int main() +{ + basic_tests(); + +// All the iterator categories + test >(); + test >(); + test >(); + test >(); + test(); + test< int*>(); +} Added: vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_iter_iter_iter_init_op.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator +// exclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, +// T init, BinaryOperation binary_op); // C++17 + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter1 first, Iter1 last, T init, Op op, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; + +// Not in place + std::exclusive_scan(first, last, std::back_inserter(v), init, op); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// In place + v.clear(); + v.assign(first, last); + std::exclusive_scan(v.begin(), v.end(), v.begin(), init, op); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = {1, 3, 5, 7, 9}; + const int pRes[] = {0, 1, 4, 9, 16}; + const int mRes[] = {1, 1, 3, 15, 105}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure + static_assert(sa == sizeof(mRes) / sizeof(mRes[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) { + test(Iter(ia), Iter(ia + i), 0, std::plus<>(), pRes, pRes + i); + test(Iter(ia), Iter(ia + i), 1, std::multiplies<>(), mRes, mRes + i); + } +} + +int main() +{ +// All the iterator categories + test >(); + test >(); + test >(); + test >(); + test(); + test< int*>(); + +// Make sure that the calculations are done using the init typedef + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::vector res; + std::exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>()); + + assert(res.size() == 10); + int j = 1; + assert(res[0] == 1); + for (size_t i = 1; i < v.size(); ++i) + { + j *= i; + assert(res[i] == j); + } + } +} + \ No newline at end of file Added: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_iter_iter_iter_init_bop_uop.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -0,0 +1,154 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, T init, +// BinaryOperation binary_op, +// UnaryOperation unary_op); + + +#include +#include +#include +#include + +#include "test_iterators.h" + +template +struct identity : std::unary_function<_Tp, _Tp> +{ + constexpr const _Tp& operator()(const _Tp& __x) const { return __x;} +}; + +template <> +struct identity +{ + template + constexpr auto operator()(_Tp&& __x) const + _NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x))) + -> decltype (_VSTD::forward<_Tp>(__x)) + { return _VSTD::forward<_Tp>(__x); } +}; + +template +void +test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; +// Test not in-place + std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// Test in-place + v.clear(); + v.assign(first, last); + std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = { 1, 3, 5, 7, 9}; + const int pResI0[] = { 0, 1, 4, 9, 16}; // with identity + const int mResI0[] = { 0, 0, 0, 0, 0}; + const int pResN0[] = { 0, -1, -4, -9, -16}; // with negate + const int mResN0[] = { 0, 0, 0, 0, 0}; + const int pResI2[] = { 2, 3, 6, 11, 18}; // with identity + const int mResI2[] = { 2, 2, 6, 30, 210}; + const int pResN2[] = { 2, 1, -2, -7, -14}; // with negate + const int mResN2[] = { 2, -2, 6, -30, 210}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0])); // just to be sure + static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0])); // just to be sure + static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0])); // just to be sure + static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0])); // just to be sure + static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0])); // just to be sure + static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0])); // just to be sure + static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0])); // just to be sure + static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) { + test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 0, pResI0, pResI0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 0, mResI0, mResI0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 0, pResN0, pResN0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 2, pResI2, pResI2 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 2, mResI2, mResI2 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 2, pResN2, pResN2 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i); + } +} + +int triangle(int n) { return n*(n+1)/2; } + +// Basic sanity +void basic_tests() +{ + { + std::vector v(10); + std::fill(v.begin(), v.end(), 3); + std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 50, std::plus<>(), identity<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 50 + (int) i * 3); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 0); + std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 30, std::plus<>(), identity<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 30 + triangle(i-1)); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 40, std::plus<>(), identity<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 40 + triangle(i)); + } + +// Make sure that the calculations are done using the init typedef + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::vector res; + std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>(), identity<>()); + + assert(res.size() == 10); + int j = 1; + assert(res[0] == 1); + for (size_t i = 1; i < res.size(); ++i) + { + j *= i; + assert(res[i] == j); + } + } +} + +int main() +{ + basic_tests(); + +// All the iterator categories + test >(); + test >(); + test >(); + test >(); + test(); + test< int*>(); +} Modified: vendor/libc++/dist/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/test/std/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -16,8 +16,10 @@ // mutex(); #include +#include int main() { + static_assert(std::is_nothrow_default_constructible::value, ""); std::mutex m; } Modified: vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -48,7 +48,6 @@ int main() assert(X::dtor_called == false); assert(static_cast(opt) == false); } - assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997 { optional opt(X{}); X::dtor_called = false; @@ -57,5 +56,4 @@ int main() assert(static_cast(opt) == false); X::dtor_called = false; } - assert(X::dtor_called == false); // TRANSITION, Clang/C2 VSO#239997 } Modified: vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -10,7 +10,7 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 // -// template T optional::value_or(U&& v) &&; +// template constexpr T optional::value_or(U&& v) &&; #include #include @@ -26,22 +26,22 @@ struct Y { int i_; - Y(int i) : i_(i) {} + constexpr Y(int i) : i_(i) {} }; struct X { int i_; - X(int i) : i_(i) {} - X(X&& x) : i_(x.i_) {x.i_ = 0;} - X(const Y& y) : i_(y.i_) {} - X(Y&& y) : i_(y.i_+1) {} + constexpr X(int i) : i_(i) {} + constexpr X(X&& x) : i_(x.i_) {x.i_ = 0;} + constexpr X(const Y& y) : i_(y.i_) {} + constexpr X(Y&& y) : i_(y.i_+1) {} friend constexpr bool operator==(const X& x, const X& y) {return x.i_ == y.i_;} }; -int main() +constexpr int test() { { optional opt(in_place, 2); @@ -65,4 +65,10 @@ int main() assert(std::move(opt).value_or(Y(3)) == 4); assert(!opt); } + return 0; +} + +int main() +{ + static_assert(test() == 0); } Added: vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/implicit_deduction_guides.pass.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/implicit_deduction_guides.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -0,0 +1,155 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// UNSUPPORTED: libcpp-no-deduction-guides + +// GCC's implementation of class template deduction is still immature and runs +// into issues with libc++. However GCC accepts this code when compiling +// against libstdc++. +// XFAIL: gcc + +// + +// Test that the constructors offered by std::basic_string are formulated +// so they're compatible with implicit deduction guides. + +#include +#include +#include + +#include "test_macros.h" +#include "archetypes.hpp" + + +// Overloads +// using A = Allocator +// using AT = std::allocator_arg_t +// --------------- +// (1) tuple(const Types&...) -> tuple +// (2) explicit tuple(const Types&...) -> tuple +// (3) tuple(AT, A const&, Types const&...) -> tuple +// (4) explicit tuple(AT, A const&, Types const&...) -> tuple +// (5) tuple(tuple const& t) -> decltype(t) +// (6) tuple(tuple&& t) -> decltype(t) +// (7) tuple(AT, A const&, tuple const& t) -> decltype(t) +// (8) tuple(AT, A const&, tuple&& t) -> decltype(t) +void test_primary_template() +{ + const std::allocator A; + const auto AT = std::allocator_arg; + { // Testing (1) + int x = 101; + std::tuple t1(42); + ASSERT_SAME_TYPE(decltype(t1), std::tuple); + std::tuple t2(x, 0.0, nullptr); + ASSERT_SAME_TYPE(decltype(t2), std::tuple); + } + { // Testing (2) + using T = ExplicitTestTypes::TestType; + static_assert(!std::is_convertible::value, ""); + + std::tuple t1(T{}); + ASSERT_SAME_TYPE(decltype(t1), std::tuple); + + const T v{}; + std::tuple t2(T{}, 101l, v); + ASSERT_SAME_TYPE(decltype(t2), std::tuple); + } + { // Testing (3) + int x = 101; + std::tuple t1(AT, A, 42); + ASSERT_SAME_TYPE(decltype(t1), std::tuple); + + std::tuple t2(AT, A, 42, 0.0, x); + ASSERT_SAME_TYPE(decltype(t2), std::tuple); + } + { // Testing (4) + using T = ExplicitTestTypes::TestType; + static_assert(!std::is_convertible::value, ""); + + std::tuple t1(AT, A, T{}); + ASSERT_SAME_TYPE(decltype(t1), std::tuple); + + const T v{}; + std::tuple t2(AT, A, T{}, 101l, v); + ASSERT_SAME_TYPE(decltype(t2), std::tuple); + } + { // Testing (5) + using Tup = std::tuple; + const Tup t(42, nullptr); + + std::tuple t1(t); + ASSERT_SAME_TYPE(decltype(t1), Tup); + } + { // Testing (6) + using Tup = std::tuple; + std::tuple t1(Tup(nullptr, 42, 'a')); + ASSERT_SAME_TYPE(decltype(t1), Tup); + } + { // Testing (7) + using Tup = std::tuple; + const Tup t(42, nullptr); + + std::tuple t1(AT, A, t); + ASSERT_SAME_TYPE(decltype(t1), Tup); + } + { // Testing (8) + using Tup = std::tuple; + std::tuple t1(AT, A, Tup(nullptr, 42, 'a')); + ASSERT_SAME_TYPE(decltype(t1), Tup); + } +} + +// Overloads +// using A = Allocator +// using AT = std::allocator_arg_t +// --------------- +// (1) tuple() -> tuple<> +// (2) tuple(AT, A const&) -> tuple<> +// (3) tuple(tuple const&) -> tuple<> +// (4) tuple(tuple&&) -> tuple<> +// (5) tuple(AT, A const&, tuple const&) -> tuple<> +// (6) tuple(AT, A const&, tuple&&) -> tuple<> +void test_empty_specialization() +{ + std::allocator A; + const auto AT = std::allocator_arg; + { // Testing (1) + std::tuple t1{}; + ASSERT_SAME_TYPE(decltype(t1), std::tuple<>); + } + { // Testing (2) + std::tuple t1{AT, A}; + ASSERT_SAME_TYPE(decltype(t1), std::tuple<>); + } + { // Testing (3) + const std::tuple<> t{}; + std::tuple t1(t); + ASSERT_SAME_TYPE(decltype(t1), std::tuple<>); + } + { // Testing (4) + std::tuple t1(std::tuple<>{}); + ASSERT_SAME_TYPE(decltype(t1), std::tuple<>); + } + { // Testing (5) + const std::tuple<> t{}; + std::tuple t1(AT, A, t); + ASSERT_SAME_TYPE(decltype(t1), std::tuple<>); + } + { // Testing (6) + std::tuple t1(AT, A, std::tuple<>{}); + ASSERT_SAME_TYPE(decltype(t1), std::tuple<>); + } +} + +int main() { + test_primary_template(); + test_empty_specialization(); +} Modified: vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -68,6 +68,28 @@ struct ThrowsCtorT { } }; +struct MoveCrashes { + int value; + MoveCrashes(int v = 0) noexcept : value{v} {} + MoveCrashes(MoveCrashes &&) noexcept { assert(false); } + MoveCrashes &operator=(MoveCrashes &&) noexcept { assert(false); return *this; } + MoveCrashes &operator=(int v) noexcept { + value = v; + return *this; + } +}; + +struct ThrowsCtorTandMove { + int value; + ThrowsCtorTandMove() : value(0) {} + ThrowsCtorTandMove(int) noexcept(false) { throw 42; } + ThrowsCtorTandMove(ThrowsCtorTandMove &&) noexcept(false) { assert(false); } + ThrowsCtorTandMove &operator=(int v) noexcept { + value = v; + return *this; + } +}; + struct ThrowsAssignT { int value; ThrowsAssignT() : value(0) {} @@ -126,7 +148,7 @@ void test_T_assignment_sfinae() { using V = std::variant; static_assert(!std::is_assignable::value, "ambiguous"); } -#endif +#endif // TEST_VARIANT_HAS_NO_REFERENCES } void test_T_assignment_basic() { @@ -163,7 +185,7 @@ void test_T_assignment_basic() { assert(v.index() == 2); assert(std::get<2>(v) == 42); } -#endif +#endif // TEST_VARIANT_HAS_NO_REFERENCES } void test_T_assignment_performs_construction() { @@ -174,9 +196,11 @@ void test_T_assignment_performs_construction() { V v(std::in_place_type, "hello"); try { v = 42; + assert(false); } catch (...) { /* ... */ } - assert(v.valueless_by_exception()); + assert(v.index() == 0); + assert(std::get<0>(v) == "hello"); } { using V = std::variant; @@ -185,7 +209,7 @@ void test_T_assignment_performs_construction() { assert(v.index() == 0); assert(std::get<0>(v).value == 42); } -#endif +#endif // TEST_HAS_NO_EXCEPTIONS } void test_T_assignment_performs_assignment() { @@ -227,7 +251,7 @@ void test_T_assignment_performs_assignment() { assert(v.index() == 1); assert(std::get<1>(v).value == 100); } -#endif +#endif // TEST_HAS_NO_EXCEPTIONS } int main() { Modified: vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp ============================================================================== --- vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Sat Jun 10 13:44:38 2017 (r319785) +++ vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Sat Jun 10 13:44:41 2017 (r319786) @@ -10,6 +10,10 @@ // UNSUPPORTED: c++98, c++03, c++11, c++14 +// The following compilers don't generate constexpr special members correctly. +// XFAIL: clang-3.5, clang-3.6, clang-3.7, clang-3.8 +// XFAIL: apple-clang-6, apple-clang-7, apple-clang-8.0 + // XFAIL: with_system_cxx_lib=macosx10.12 // XFAIL: with_system_cxx_lib=macosx10.11 // XFAIL: with_system_cxx_lib=macosx10.10 @@ -35,11 +39,6 @@ struct NoCopy { NoCopy &operator=(const NoCopy &) = default; }; -struct NothrowCopy { - NothrowCopy(const NothrowCopy &) noexcept = default; - NothrowCopy &operator=(const NothrowCopy &) noexcept = default; -}; - struct CopyOnly { CopyOnly(const CopyOnly &) = default; CopyOnly(CopyOnly &&) = delete; @@ -73,7 +72,7 @@ struct CopyAssign { ++alive; ++copy_construct; } - CopyAssign(CopyAssign &&o) : value(o.value) { + CopyAssign(CopyAssign &&o) noexcept : value(o.value) { o.value = -1; ++alive; ++move_construct; @@ -83,7 +82,7 @@ struct CopyAssign { ++copy_assign; return *this; } - CopyAssign &operator=(CopyAssign &&o) { + CopyAssign &operator=(CopyAssign &&o) noexcept { value = o.value; o.value = -1; ++move_assign; @@ -108,6 +107,48 @@ struct CopyDoesThrow { CopyDoesThrow &operator=(const CopyDoesThrow &) noexcept(false); }; + +struct NTCopyAssign { + constexpr NTCopyAssign(int v) : value(v) {} + NTCopyAssign(const NTCopyAssign &) = default; + NTCopyAssign(NTCopyAssign &&) = default; + NTCopyAssign &operator=(const NTCopyAssign &that) { + value = that.value; + return *this; + }; + NTCopyAssign &operator=(NTCopyAssign &&) = delete; + int value; +}; + +static_assert(!std::is_trivially_copy_assignable::value, ""); +static_assert(std::is_copy_assignable::value, ""); + +struct TCopyAssign { + constexpr TCopyAssign(int v) : value(v) {} + TCopyAssign(const TCopyAssign &) = default; + TCopyAssign(TCopyAssign &&) = default; + TCopyAssign &operator=(const TCopyAssign &) = default; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***