diff --git a/libcxx/cmake/caches/Generic-debug.cmake b/libcxx/cmake/caches/Generic-debug.cmake new file mode 100644 --- /dev/null +++ b/libcxx/cmake/caches/Generic-debug.cmake @@ -0,0 +1,2 @@ +set(LIBCXX_TEST_PARAMS "std=c++2b" "debug_level=1" "additional_features=LIBCXX-DEBUG-FIXME" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "std=c++2b" CACHE STRING "") diff --git a/libcxx/include/__string b/libcxx/include/__string --- a/libcxx/include/__string +++ b/libcxx/include/__string @@ -256,7 +256,6 @@ _CharT* char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -339,7 +338,6 @@ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() ? _VSTD::__copy_constexpr(__s1, __s2, __n) : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); @@ -442,7 +440,6 @@ static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() ? _VSTD::__copy_constexpr(__s1, __s2, __n) : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n); @@ -576,7 +573,6 @@ static _LIBCPP_CONSTEXPR_AFTER_CXX17 char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); return __libcpp_is_constant_evaluated() ? _VSTD::__copy_constexpr(__s1, __s2, __n) : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); @@ -752,7 +748,6 @@ char16_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -872,7 +867,6 @@ char32_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); diff --git a/libcxx/include/iterator b/libcxx/include/iterator --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -476,10 +476,10 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 void advance(_InputIter& __i, _Distance __orig_n) { - _LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, - "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; _IntegralSize __n = __orig_n; + _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, + "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); } diff --git a/libcxx/include/span b/libcxx/include/span --- a/libcxx/include/span +++ b/libcxx/include/span @@ -200,7 +200,7 @@ using const_pointer = const _Tp *; using reference = _Tp &; using const_reference = const _Tp &; - using iterator = __wrap_iter; + using iterator = pointer; using reverse_iterator = _VSTD::reverse_iterator; static constexpr size_type extent = _Extent; @@ -375,7 +375,7 @@ using const_pointer = const _Tp *; using reference = _Tp &; using const_reference = const _Tp &; - using iterator = __wrap_iter; + using iterator = pointer; using reverse_iterator = _VSTD::reverse_iterator; static constexpr size_type extent = dynamic_extent; diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -2497,14 +2497,21 @@ { size_type __sz = size(); __grow_by(__cap, __n - __cap, __sz, 0, __sz); + pointer __p = __get_pointer(); + for (; __first != __last; ++__first, ++__p) + traits_type::assign(*__p, *__first); + traits_type::assign(*__p, value_type()); + __set_size(__n); } else + { + pointer __p = __get_pointer(); + for (; __first != __last; ++__first, ++__p) + traits_type::assign(*__p, *__first); + traits_type::assign(*__p, value_type()); + __set_size(__n); __invalidate_iterators_past(__n); - pointer __p = __get_pointer(); - for (; __first != __last; ++__first, ++__p) - traits_type::assign(*__p, *__first); - traits_type::assign(*__p, value_type()); - __set_size(__n); + } return *this; } diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp --- a/libcxx/src/debug.cpp +++ b/libcxx/src/debug.cpp @@ -438,7 +438,7 @@ __i_node* j = __find_iterator(__j); __c_node* ci = i != nullptr ? i->__c_ : nullptr; __c_node* cj = j != nullptr ? j->__c_ : nullptr; - return ci != nullptr && ci == cj; + return ci == cj; } void diff --git a/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp --- a/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp +++ b/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03 +// UNSUPPORTED: debug_level_0, debug_level_1 // diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp @@ -18,6 +18,8 @@ // UNSUPPORTED: apple-clang-9 // UNSUPPORTED: gcc-5 +// XFAIL: LIBCXX-DEBUG-FIXME + // All entities to which libc++ applies [[nodiscard]] as an extension should // be tested here and in nodiscard_extensions.fail.cpp. They should also // be listed in `UsingLibcxx.rst` in the documentation for the extension. diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp --- a/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp @@ -79,7 +79,9 @@ assert(ia[0] == static_cast(N)-1); assert(ia[N-1] == 0); assert(std::is_sorted(ia, ia+N, std::greater())); +#ifndef _LIBCPP_DEBUG assert(pred.count() <= (N-1)); +#endif } delete [] ia; } diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp --- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp @@ -35,7 +35,7 @@ assert(r->second == 3); const VT v2(3.5, 4); - r = c.insert(c.end(), v2); + r = c.insert(r, v2); assert(c.size() == 1); assert(r->first == 3.5); assert(r->second == 3); diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp --- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp @@ -38,7 +38,7 @@ assert(r->first == 3.5); assert(r->second == 3); - r = c.insert(c.end(), P(3.5, static_cast(4))); + r = c.insert(r, P(3.5, static_cast(4))); assert(c.size() == 1); assert(r->first == 3.5); assert(r->second == 3); @@ -64,7 +64,7 @@ assert(r->first == 3); assert(r->second == 3); - r = c.insert(c.end(), P(3, 4)); + r = c.insert(r, P(3, 4)); assert(c.size() == 1); assert(r->first == 3); assert(r->second == 3); @@ -91,7 +91,7 @@ assert(r->first == 3.5); assert(r->second == 3); - r = c.insert(c.end(), P(3.5, static_cast(4))); + r = c.insert(r, P(3.5, static_cast(4))); assert(c.size() == 1); assert(r->first == 3.5); assert(r->second == 3); @@ -118,7 +118,7 @@ assert(r->first == 3); assert(r->second == 3); - r = c.insert(c.end(), P(3, 4)); + r = c.insert(r, P(3, 4)); assert(c.size() == 1); assert(r->first == 3); assert(r->second == 3); @@ -143,7 +143,7 @@ assert(r->first == 3.5); assert(r->second == 3); - r = c.insert(c.end(), {3.5, 4}); + r = c.insert(r, {3.5, 4}); assert(c.size() == 1); assert(r->first == 3.5); assert(r->second == 3); diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp @@ -35,7 +35,7 @@ assert(r->second == 3); const VT v2(3.5, 4); - r = c.insert(c.end(), v2); + r = c.insert(r, v2); assert(c.size() == 2); assert(r->first == 3.5); assert(r->second == 4); diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp @@ -33,7 +33,7 @@ assert(c.size() == 1); assert(*r == 3.5); - r = c.insert(c.end(), v1); + r = c.insert(r, v1); assert(c.size() == 2); assert(*r == 3.5); diff --git a/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp --- a/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp @@ -33,17 +33,17 @@ assert(c.size() == 1); assert(*r == 3.5); - r = c.insert(e, v1); + r = c.insert(r, v1); assert(c.size() == 1); assert(*r == 3.5); const VT v2(4.5); - r = c.insert(e, v2); + r = c.insert(c.end(), v2); assert(c.size() == 2); assert(*r == 4.5); const VT v3(5.5); - r = c.insert(e, v3); + r = c.insert(c.end(), v3); assert(c.size() == 3); assert(*r == 5.5); } diff --git a/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp --- a/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp @@ -28,7 +28,8 @@ typedef C::iterator R; typedef double P; C c; - R r = c.insert(c.end(), P(3.5)); + typename C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5)); assert(c.size() == 1); assert(*r == 3.5); @@ -50,7 +51,8 @@ typedef C::iterator R; typedef MoveOnly P; C c; - R r = c.insert(c.end(), P(3)); + typename C::const_iterator e = c.end(); + R r = c.insert(e, P(3)); assert(c.size() == 1); assert(*r == 3); @@ -72,7 +74,8 @@ typedef C::iterator R; typedef double P; C c; - R r = c.insert(c.end(), P(3.5)); + typename C::const_iterator e = c.end(); + R r = c.insert(e, P(3.5)); assert(c.size() == 1); assert(*r == 3.5); @@ -94,7 +97,8 @@ typedef C::iterator R; typedef MoveOnly P; C c; - R r = c.insert(c.end(), P(3)); + typename C::const_iterator e = c.end(); + R r = c.insert(e, P(3)); assert(c.size() == 1); assert(*r == 3); diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp --- a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/path.factory.pass.cpp @@ -42,7 +42,7 @@ assert(p == In1); } { - path p = fs::u8path(In3); + path p = fs::u8path(In2.data()); assert(p == In1); } { @@ -65,7 +65,7 @@ assert(p == In1); } { - path p = fs::u8path(u8In3); + path p = fs::u8path(u8In2.data()); assert(p == In1); } { diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp --- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.proximate/proximate.pass.cpp @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +// XFAIL: LIBCXX-DEBUG-FIXME + // UNSUPPORTED: c++03 // diff --git a/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp b/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template // OutputIterator exclusive_scan(InputIterator first, InputIterator last, @@ -23,55 +24,39 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, T init, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Not in place - std::exclusive_scan(first, last, v.begin(), init); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::exclusive_scan(first, last, out, init); + assert(std::equal(out, end, rFirst, rLast)); -// In place - std::copy(first, last, v.begin()); - std::exclusive_scan(v.begin(), v.end(), v.begin(), init); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::exclusive_scan(out, end, out, init); + assert(std::equal(out, end, rFirst, rLast)); } template TEST_CONSTEXPR_CXX20 void test() { - int ia[] = {1, 3, 5, 7, 9}; + 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 ) + for (unsigned int i = 0; i < sa; ++i) { test(Iter(ia), Iter(ia + i), 0, pRes, pRes + i); + } } constexpr size_t triangle(size_t n) { return n*(n+1)/2; } diff --git a/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp b/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template // OutputIterator @@ -24,42 +25,25 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, T init, Op op, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, T init, Op op, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Not in place - std::exclusive_scan(first, last, v.begin(), init, op); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::exclusive_scan(first, last, out, init, op); + assert(std::equal(out, end, rFirst, rLast)); -// In place - std::copy(first, last, v.begin()); - std::exclusive_scan(v.begin(), v.end(), v.begin(), init, op); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::exclusive_scan(out, end, out, init, op); + assert(std::equal(out, end, rFirst, rLast)); } @@ -67,7 +51,7 @@ TEST_CONSTEXPR_CXX20 void test() { - int ia[] = {1, 3, 5, 7, 9}; + 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]); @@ -77,7 +61,7 @@ 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); - } + } } TEST_CONSTEXPR_CXX20 bool @@ -95,18 +79,8 @@ { std::array v; std::iota(v.begin(), v.end(), static_cast(1)); - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector res; - std::exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>()); -#else std::array res; std::exclusive_scan(v.begin(), v.end(), res.begin(), 1, std::multiplies<>()); -#endif assert(res.size() == 10); size_t j = 1; diff --git a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template // OutputIterator inclusive_scan(InputIterator first, InputIterator last, @@ -23,42 +24,25 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Not in place - std::inclusive_scan(first, last, v.begin()); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::inclusive_scan(first, last, out); + assert(std::equal(out, end, rFirst, rLast)); -// In place - std::copy(first, last, v.begin()); - std::inclusive_scan(v.begin(), v.end(), v.begin()); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::inclusive_scan(out, end, out); + assert(std::equal(out, end, rFirst, rLast)); } @@ -66,13 +50,14 @@ TEST_CONSTEXPR_CXX20 void test() { - int ia[] = {1, 3, 5, 7, 9}; + int ia[] = {1, 3, 5, 7, 9}; const int pRes[] = {1, 4, 9, 16, 25}; 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 ) + for (unsigned int i = 0; i < sa; ++i ) { test(Iter(ia), Iter(ia + i), pRes, pRes + i); + } } constexpr size_t triangle(size_t n) { return n*(n+1)/2; } @@ -106,18 +91,8 @@ } { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector v, res; - std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res)); -#else std::array v, res; std::inclusive_scan(v.begin(), v.end(), res.begin()); -#endif assert(res.empty()); } } diff --git a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template // OutputIterator @@ -24,42 +25,25 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, Op op, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, Op op, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Not in place - std::inclusive_scan(first, last, v.begin(), op); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::inclusive_scan(first, last, out, op); + assert(std::equal(out, end, rFirst, rLast)); -// In place - std::copy(first, last, v.begin()); - std::inclusive_scan(v.begin(), v.end(), v.begin(), op); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::inclusive_scan(out, end, out, op); + assert(std::equal(out, end, rFirst, rLast)); } @@ -67,7 +51,7 @@ TEST_CONSTEXPR_CXX20 void test() { - int ia[] = {1, 3, 5, 7, 9}; + int ia[] = {1, 3, 5, 7, 9}; const int pRes[] = {1, 4, 9, 16, 25}; const int mRes[] = {1, 3, 15, 105, 945}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); @@ -77,7 +61,7 @@ for (unsigned int i = 0; i < sa; ++i ) { test(Iter(ia), Iter(ia + i), std::plus<>(), pRes, pRes + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), mRes, mRes + i); - } + } } constexpr size_t triangle(size_t n) { return n*(n+1)/2; } @@ -111,18 +95,8 @@ } { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector v, res; - std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>()); -#else std::array v, res; std::inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>()); -#endif assert(res.empty()); } } diff --git a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template // OutputIterator @@ -24,42 +25,25 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, Op op, T init, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, Op op, T init, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Not in place - std::inclusive_scan(first, last, v.begin(), op, init); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::inclusive_scan(first, last, out, op, init); + assert(std::equal(out, end, rFirst, rLast)); -// In place - std::copy(first, last, v.begin()); - std::inclusive_scan(v.begin(), v.end(), v.begin(), op, init); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::inclusive_scan(out, end, out, op, init); + assert(std::equal(out, end, rFirst, rLast)); } @@ -67,7 +51,7 @@ TEST_CONSTEXPR_CXX20 void test() { - int ia[] = {1, 3, 5, 7, 9}; + int ia[] = {1, 3, 5, 7, 9}; const int pRes[] = {1, 4, 9, 16, 25}; const int mRes[] = {1, 3, 15, 105, 945}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); @@ -77,7 +61,7 @@ for (unsigned int i = 0; i < sa; ++i ) { test(Iter(ia), Iter(ia + i), std::plus<>(), 0, pRes, pRes + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), 1, mRes, mRes + i); - } + } } constexpr size_t triangle(size_t n) { return n*(n+1)/2; } @@ -111,18 +95,8 @@ } { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector v, res; - std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), size_t{40}); -#else std::array v, res; std::inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>(), size_t{40}); -#endif assert(res.empty()); } @@ -130,18 +104,8 @@ { std::array v; std::iota(v.begin(), v.end(), static_cast(1)); - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector res; - std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), size_t{1}); -#else std::array res; std::inclusive_scan(v.begin(), v.end(), res.begin(), std::multiplies<>(), size_t{1}); -#endif assert(res.size() == 10); size_t j = 1; diff --git a/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp b/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template @@ -26,14 +27,9 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif struct add_one { template @@ -42,41 +38,28 @@ } }; -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Test not in-place - std::transform_exclusive_scan(first, last, v.begin(), init, bop, uop); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::transform_exclusive_scan(first, last, out, init, bop, uop); + assert(std::equal(out, end, rFirst, rLast)); -// Test in-place - std::copy(first, last, v.begin()); - std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::transform_exclusive_scan(out, end, out, init, bop, uop); + assert(std::equal(out, end, rFirst, rLast)); } - template TEST_CONSTEXPR_CXX20 void test() { - int ia[] = { 1, 3, 5, 7, 9 }; + int ia[] = { 1, 3, 5, 7, 9 }; const int pResI0[] = { 0, 2, 6, 12, 20 }; // with add_one const int mResI0[] = { 0, 0, 0, 0, 0 }; const int pResN0[] = { 0, -1, -4, -9, -16 }; // with negate @@ -104,7 +87,7 @@ test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_one{}, 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); - } + } } constexpr size_t triangle(size_t n) { return n*(n+1)/2; } @@ -138,18 +121,8 @@ } { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector v, res; - std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), size_t{40}, std::plus<>(), add_one{}); -#else std::array v, res; std::transform_exclusive_scan(v.begin(), v.end(), res.begin(), size_t{40}, std::plus<>(), add_one{}); -#endif assert(res.empty()); } @@ -157,18 +130,8 @@ { std::array v; std::iota(v.begin(), v.end(), static_cast(1)); - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector res; - std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), size_t{1}, std::multiplies<>(), add_one{}); -#else std::array res; std::transform_exclusive_scan(v.begin(), v.end(), res.begin(), size_t{1}, std::multiplies<>(), add_one{}); -#endif assert(res.size() == 10); size_t j = 1; diff --git a/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp b/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp @@ -1,4 +1,3 @@ - //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -7,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template @@ -27,49 +27,32 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif struct add_one { template - constexpr auto operator()(T x) const noexcept { - return static_cast(x + 1); + constexpr T operator()(T x) const { + return x + 1; } }; -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, BOp bop, UOp uop, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, BOp bop, UOp uop, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Test not in-place - std::transform_inclusive_scan(first, last, v.begin(), bop, uop); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::transform_inclusive_scan(first, last, out, bop, uop); + assert(std::equal(out, end, rFirst, rLast)); -// Test in-place - std::copy(first, last, v.begin()); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::transform_inclusive_scan(out, end, out, bop, uop); + assert(std::equal(out, end, rFirst, rLast)); } @@ -77,7 +60,7 @@ TEST_CONSTEXPR_CXX20 void test() { - int ia[] = { 1, 3, 5, 7, 9 }; + int ia[] = { 1, 3, 5, 7, 9 }; const int pResI0[] = { 2, 6, 12, 20, 30 }; // with add_one const int mResI0[] = { 2, 8, 48, 384, 3840 }; const int pResN0[] = { -1, -4, -9, -16, -25 }; // with negate @@ -93,7 +76,7 @@ test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_one{}, mResI0, mResI0 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), pResN0, pResN0 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), mResN0, mResN0 + i); - } + } } constexpr size_t triangle(size_t n) { return n*(n+1)/2; } @@ -127,18 +110,8 @@ } { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector v, res; - std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), add_one{}); -#else std::array v, res; std::transform_inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>(), add_one{}); -#endif assert(res.empty()); } } diff --git a/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp b/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp --- a/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp @@ -6,11 +6,12 @@ // //===----------------------------------------------------------------------===// -// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: clang-8 // UNSUPPORTED: gcc-9 +// + // Became constexpr in C++20 // template @@ -27,49 +28,32 @@ #include #include #include -#include #include "test_macros.h" #include "test_iterators.h" -// FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER > 17 -#include -#endif struct add_one { template - constexpr auto operator()(T x) const noexcept { - return static_cast(x + 1); + constexpr T operator()(T x) const { + return x + 1; } }; -template +template TEST_CONSTEXPR_CXX20 void -test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast) +test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, const T *rFirst, const T *rLast) { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 - size_t size = std::distance(first, last); -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - - std::vector::value_type> v(size); -#else - assert((size <= 5) && "Increment the size of the array"); - typename std::iterator_traits::value_type b[5]; - std::span::value_type> v{b, size}; -#endif + assert((rLast - rFirst) <= 5); // or else increase the size of "out" + T out[5]; -// Test not in-place - std::transform_inclusive_scan(first, last, v.begin(), bop, uop, init); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // Not in place + T *end = std::transform_inclusive_scan(first, last, out, bop, uop, init); + assert(std::equal(out, end, rFirst, rLast)); -// Test in-place - std::copy(first, last, v.begin()); - std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop, init); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + // In place + std::copy(first, last, out); + end = std::transform_inclusive_scan(out, end, out, bop, uop, init); + assert(std::equal(out, end, rFirst, rLast)); } @@ -77,7 +61,7 @@ TEST_CONSTEXPR_CXX20 void test() { - int ia[] = { 1, 3, 5, 7, 9 }; + int ia[] = { 1, 3, 5, 7, 9 }; const int pResI0[] = { 2, 6, 12, 20, 30 }; // with add_one const int mResI0[] = { 0, 0, 0, 0, 0 }; const int pResN0[] = { -1, -4, -9, -16, -25 }; // with negate @@ -105,7 +89,7 @@ test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_one{}, 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); - } + } } constexpr size_t triangle(size_t n) { return n*(n+1)/2; } @@ -139,18 +123,8 @@ } { - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector v, res; - std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), add_one{}, size_t{1}); -#else std::array v, res; std::transform_inclusive_scan(v.begin(), v.end(), res.begin(), std::plus<>(), add_one{}, size_t{1}); -#endif assert(res.empty()); } @@ -158,18 +132,8 @@ { std::array v; std::iota(v.begin(), v.end(), static_cast(1)); - // C++17 doesn't test constexpr so can use a vector. - // C++20 can use vector in constexpr evaluation, but both libc++ and MSVC - // don't have the support yet. In these cases use a std::span for the test. - // FIXME Remove constexpr vector workaround introduced in D90569 -#if TEST_STD_VER < 20 || \ - (defined(__cpp_lib_constexpr_vector) && __cpp_lib_constexpr_vector >= 201907L) - std::vector res; - std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), add_one{}, size_t{1}); -#else std::array res; std::transform_inclusive_scan(v.begin(), v.end(), res.begin(), std::multiplies<>(), add_one{}, size_t{1}); -#endif assert(res.size() == 10); size_t j = 2; diff --git a/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp @@ -22,69 +22,46 @@ #include "test_macros.h" -int main(int, char**) +template +void test() { { // N3644 testing - typedef std::string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; + typename C::iterator ii1{}, ii2{}; + typename C::iterator ii4 = ii1; + typename C::const_iterator cii{}; assert ( ii1 == ii2 ); assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } - { // N3644 testing - typedef std::wstring C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); + assert (!(ii1 != ii2 )); + + assert ( (ii1 == cii )); + assert ( (cii == ii1 )); + assert (!(ii1 != cii )); + assert (!(cii != ii1 )); + assert (!(ii1 < cii )); + assert (!(cii < ii1 )); + assert ( (ii1 <= cii )); + assert ( (cii <= ii1 )); + assert (!(ii1 > cii )); + assert (!(cii > ii1 )); + assert ( (ii1 >= cii )); + assert ( (cii >= ii1 )); + assert (cii - ii1 == 0); + assert (ii1 - cii == 0); } +} + +int main(int, char**) +{ + test(); + test(); #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L - { - typedef std::u8string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } + test(); #endif - { // N3644 testing - typedef std::u16string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } - - { // N3644 testing - typedef std::u32string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } + test(); + test(); - return 0; + return 0; } diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -53,66 +53,6 @@ # - wait - - label: "C++03" - command: "libcxx/utils/ci/run-buildbot generic-cxx03" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "C++11" - command: "libcxx/utils/ci/run-buildbot generic-cxx11" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "C++14" - command: "libcxx/utils/ci/run-buildbot generic-cxx14" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "C++17" - command: "libcxx/utils/ci/run-buildbot generic-cxx17" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "C++20" - command: "libcxx/utils/ci/run-buildbot generic-cxx20" - artifact_paths: - - "**/test-results.xml" - - "**/*.abilist" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - label: "C++2b" command: "libcxx/utils/ci/run-buildbot generic-cxx2b" artifact_paths: @@ -125,337 +65,14 @@ - exit_status: -1 # Agent was lost limit: 2 - - label: "MacOS C++20" - command: "libcxx/utils/ci/run-buildbot generic-cxx20" + - label: "Debug iterators" + command: "libcxx/utils/ci/run-buildbot generic-debug" artifact_paths: - "**/test-results.xml" - "**/*.abilist" - agents: - queue: "libcxx-builders-macos" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "GCC/C++20" - command: "libcxx/utils/ci/run-buildbot generic-gcc" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - # - # All other supported configurations of libc++. - # - - wait - - - label: "-fno-exceptions" - command: "libcxx/utils/ci/run-buildbot generic-noexceptions" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Static libraries" - command: "libcxx/utils/ci/run-buildbot generic-static" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "ASAN" - command: "libcxx/utils/ci/run-buildbot generic-asan" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "TSAN" - command: "libcxx/utils/ci/run-buildbot generic-tsan" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "UBSAN" - command: "libcxx/utils/ci/run-buildbot generic-ubsan" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "With LLVM's libunwind" - command: "libcxx/utils/ci/run-buildbot generic-with_llvm_unwinder" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Single-threaded" - command: "libcxx/utils/ci/run-buildbot generic-singlethreaded" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "No debug mode" - command: "libcxx/utils/ci/run-buildbot generic-no-debug" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "No Filesystem" - command: "libcxx/utils/ci/run-buildbot generic-no-filesystem" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "No random device" - command: "libcxx/utils/ci/run-buildbot generic-no-random_device" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "No locale" - command: "libcxx/utils/ci/run-buildbot generic-no-localization" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Benchmarks" - command: "libcxx/utils/ci/run-buildbot benchmarks" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Documentation" - command: "libcxx/utils/ci/run-buildbot documentation" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Legacy standalone build" - command: "libcxx/utils/ci/run-buildbot legacy-standalone" - artifact_paths: - - "**/test-results.xml" agents: queue: "libcxx-builders" retry: automatic: - exit_status: -1 # Agent was lost limit: 2 - - - label: "Unified standalone build" - command: "libcxx/utils/ci/run-buildbot unified-standalone" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Runtimes build" - command: "libcxx/utils/ci/run-buildbot runtimes-build" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Windows" - # TODO: The CI runner doesn't have bash in the path currently. Once it - # has that, remove the absolute path and just call 'bash' here. - command: "\"\\Program Files\\Git\\usr\\bin\\bash\" libcxx/utils/ci/run-buildbot generic-win" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "windows" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - # Build with the configuration we use to generate libc++.dylib on Apple platforms - - label: "Apple system" - command: "libcxx/utils/ci/run-buildbot x86_64-apple-system" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-macos" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Apple system -fno-exceptions" - command: "libcxx/utils/ci/run-buildbot x86_64-apple-system-noexceptions" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-macos" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - # Test back-deployment to older Apple platforms - - label: "Apple back-deployment macosx10.9" - command: "libcxx/utils/ci/run-buildbot x86_64-apple-system-backdeployment-10.9" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-macos10.15" # TODO: For now, we're running the back-deployment tests for 10.9 on 10.15, because we don't have proper 10.9 machines - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Apple back-deployment macosx10.15" - command: "libcxx/utils/ci/run-buildbot x86_64-apple-system-backdeployment-10.15" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-macos10.15" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "AArch64" - command: "libcxx/utils/ci/run-buildbot aarch64" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "aarch64" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "AArch64 -fno-exceptions" - command: "libcxx/utils/ci/run-buildbot aarch64-noexceptions" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "aarch64" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Armv8" - command: "libcxx/utils/ci/run-buildbot armv8" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Armv8 -fno-exceptions" - command: "libcxx/utils/ci/run-buildbot armv8-noexceptions" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Armv7" - command: "libcxx/utils/ci/run-buildbot armv7" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" # Compiling for v7, running on v8 hardware - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 - - - label: "Armv7 -fno-exceptions" - command: "libcxx/utils/ci/run-buildbot armv7-noexceptions" - artifact_paths: - - "**/test-results.xml" - agents: - queue: "libcxx-builders-linaro-arm" - arch: "armv8l" # Compiling for v7, running on v8 hardware - retry: - automatic: - - exit_status: -1 # Agent was lost - limit: 2 diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot --- a/libcxx/utils/ci/run-buildbot +++ b/libcxx/utils/ci/run-buildbot @@ -514,6 +514,11 @@ echo "+++ Running the libc++ tests" ${NINJA} -vC "${BUILD_DIR}" check-cxx ;; +generic-debug) + clean + generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-debug.cmake" + check-cxx-cxxabi +;; *) echo "${BUILDER} is not a known configuration" exit 1 diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py --- a/libcxx/utils/libcxx/test/config.py +++ b/libcxx/utils/libcxx/test/config.py @@ -481,6 +481,7 @@ self.lit_config.fatal('Invalid value for debug_level "%s".' % debug_level) self.cxx.compile_flags += ['-D_LIBCPP_DEBUG=%s' % debug_level] + self.config.available_features.add('debug_level_%s' % debug_level) def configure_sanitizer(self): san = self.get_lit_conf('use_sanitizer', '').strip() diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py --- a/libcxx/utils/libcxx/test/dsl.py +++ b/libcxx/utils/libcxx/test/dsl.py @@ -283,9 +283,12 @@ configuration to produce the actual flag (as a string). """ def __init__(self, flag): + print('AddFlag.__init__: flag is %r' % flag) + assert flag is not None self._getFlag = lambda config: flag(config) if callable(flag) else flag def applyTo(self, config): + print('AddFlag.applyTo: config is %r' % config) flag = self._getFlag(config) assert hasCompileFlag(config, flag), "Trying to enable flag {}, which is not supported".format(flag) config.substitutions = _appendToSubstitution(config.substitutions, '%{flags}', flag)