summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
Commit message (Collapse)AuthorAgeFilesLines
* [libcxx] [test] Add casts to avoid signed/unsigned mismatch warnings on MSVC++Billy Robert O'Neal III2020-01-143-3/+3
| | | | A bug was filed that these warnings should not be emitted as DevCom-883961. ( https://developercommunity.visualstudio.com/content/problem/883961/c4389-signedunsigned-mismatch-should-not-be-emitte.html )
* [libcxx] [test] Disable refwrap/weak_result.pass.cpp in C++20 mode (broken ↵Billy Robert O'Neal III2020-01-081-0/+2
| | | | by P0357R3)
* [libcxx][test] Fix span tests.Stephan T. Lavavej2020-01-086-38/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | span.cons/container.pass.cpp N4842 22.7.3.2 [span.cons]/13 constrains span's range constructor for ranges::contiguous_range (among other criteria). 24.4.5 [range.refinements]/2 says that contiguous_range requires data(), and (via contiguous_range, random_access_range, bidirectional_range, forward_range, input_range, range) it also requires begin() and end() (see 24.4.2 [range.range]/1). Therefore, IsAContainer needs to provide begin() and end(). (Detected by MSVC's concept-constrained implementation.) span.cons/stdarray.pass.cpp This test uses std::array, so it must include <array>. <span> isn't guaranteed to drag in <array>. (Detected by MSVC's implementation which uses a forward declaration to avoid dragging in <array>, for increased compiler throughput.) span.objectrep/as_bytes.pass.cpp span.objectrep/as_writable_bytes.pass.cpp Testing `sp.extent == std::dynamic_extent` triggers MSVC warning C4127 "conditional expression is constant". Using `if constexpr` is a simple way to avoid this without disrupting anyone else (as span requires C++20 mode). span.tuple/get.pass.cpp 22.7.3.2 [span.cons]/4.3: "Preconditions: If extent is not equal to dynamic_extent, then count is equal to extent." These lines were triggering undefined behavior (detected by assertions in MSVC's implementation). I changed the count arguments in the first two chunks, followed by changing the span extents, in order to preserve the test's coverage and follow the existing pattern. span.cons/span.pass.cpp 22.7.3.2 [span.cons]/18.1 constrains span's converting constructor with "Extent == dynamic_extent || Extent == OtherExtent is true". This means that converting from dynamic extent to static extent is not allowed. (Other constructors tested elsewhere, like span(It first, size_type count), can be used to write such code.) As this is the test for the converting constructor, I have: * Removed the "dynamic -> static" case from checkCV(), which is comprehensive. * Changed the initialization of std::span<T, 0> s1{}; in testConstexprSpan() and testRuntimeSpan(), because s1 is used below. * Removed ASSERT_NOEXCEPT(std::span<T, 0>{s0}); from those functions, as they are otherwise comprehensive. * Deleted testConversionSpan() entirely. Note that this could never compile (it had a bool return type, but forgot to say `return`). And it couldn't have provided useful coverage, as the /18.2 constraint "OtherElementType(*)[] is convertible to ElementType(*)[]" permits only cv-qualifications, which are already tested by checkCV().
* [libcxx] [test] Include missing headers. (NFC)Stephan T. Lavavej2019-12-1310-0/+13
| | | | | | | | libcxx/test/std/containers/sequences/array/at.pass.cpp Need to include <stdexcept> for std::out_of_range. libcxx/test/std/localization/locale.categories/category.time/* Need to include <ios> for std::ios.
* [libcxx] [test] Fix valarray UB and MSVC warnings.Stephan T. Lavavej2019-12-128-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [libcxx] [test] Calling min and max on an empty valarray is UB. libcxx/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp libcxx/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp The calls `v1.min();` and `v1.max();` were emitting nodiscard warnings with MSVC's STL. Upon closer inspection, these calls were triggering undefined behavior. N4842 [valarray.members] says: "T min() const; 8 Preconditions: size() > 0 is true. T max() const; 10 Preconditions: size() > 0 is true." As these tests already provide coverage for non-empty valarrays (immediately above), I've simply deleted the code for empty valarrays. [libcxx] [test] Add macros to msvc_stdlib_force_include.h (NFC). libcxx/test/support/msvc_stdlib_force_include.h These macros are being used by: libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp Defining them to nothing allows that test to pass. [libcxx] [test] Silence MSVC warning C5063 for is_constant_evaluated (NFC). libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.pass.cpp This test is intentionally writing code that MSVC intentionally warns about, so the warning should be silenced. Additionally, comment an endif for clarity. [libcxx] [test] Silence MSVC warning C4127 (NFC). libcxx/test/support/charconv_test_helpers.h MSVC avoids emitting this warning when it sees a single constexpr value being tested, but this condition is a mix of compile-time and run-time. Using push-disable-pop is the least intrusive way to silence this. [libcxx] [test] Silence MSVC truncation warning (NFC). libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp This test is intentionally truncating float to int, which MSVC intentionally warns about, so push-disable-pop is necessary. [libcxx] [test] Avoid truncation warnings in erase_if tests (NFC). libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp libcxx/test/std/containers/associative/multimap/multimap.erasure/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.map/erase_if.pass.cpp libcxx/test/std/containers/unord/unord.multimap/erase_if.pass.cpp These tests use maps with `short` keys and values, emitting MSVC truncation warnings from `int`. Adding `static_cast` to `key_type` and `mapped_type` avoids these warnings. As these tests require C++20 mode (or newer), for brevity I've changed the multimap tests to use emplace to initialize the test data. This has no effect on the erase_if testing.
* [libc++] Cleanup and enable multiple warnings.Eric Fiselier2019-12-123-0/+8
| | | | | | | | | | Too many warnings are being disabled too quickly. Warnings are important to keeping libc++ correct. This patch re-enables two warnings: -Wconstant-evaluated and -Wdeprecated-copy. In future, all warnings disabled for the test suite should require an attached bug. The bug should state the plan for re-enabling that warning, or a strong case why it should remain disabled.
* Fix _LIBCPP_HAS_ definitions for Android.Dan Albert2019-11-184-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Android added quick_exit()/at_quick_exit() in API level 21, aligned_alloc() in API level 28, and timespec_get() in API level 29, but has the other C11 features at all API levels (since they're basically just coming from clang directly). _LIBCPP_HAS_QUICK_EXIT and _LIBCPP_HAS_TIMESPEC_GET already existed, so we can reuse them. (And use _LIBCPP_HAS_TIMESPEC_GET in a few more places where _LIBCPP_HAS_C11_FEATURES has been used as a proxy. This isn't correct for Android.) _LIBCPP_HAS_ALIGNED_ALLOC is added, to cover aligned_alloc() (obviously). Add a missing std:: before aligned_alloc in a cstdlib test, and remove a couple of !defined(_WIN32)s now that we're explicitly testing TEST_HAS_ALIGNED_ALLOC rather than TEST_HAS_C11_FEATURES. Reviewers: danalbert, EricWF, mclow.lists Reviewed By: danalbert Subscribers: srhines, christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D69929
* [libc++] Add C++20 contiguous_iterator_tag.Eric Fiselier2019-11-162-1/+35
| | | | | This work is part of an ongoing effort to allow libc++ to optimize user provided contiguous iterators.
* [libc++] [chrono] Fix year_month_weekday::ok() implementation.Marek Kurdej2019-11-151-3/+23
| | | | | | | | | | | | Reviewers: ldionne, EricWF, mclow.lists Reviewed By: mclow.lists Subscribers: christof, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D70282
* [libc++][P1872] span should have size_type, not index_type.Louis Dionne2019-11-1411-16/+16
| | | | | | Thanks to Marek Kurdej for the patch. Differential Revision: https://reviews.llvm.org/D70206
* [libc++] [P1612] Add missing feature-test macro __cpp_lib_endian.Louis Dionne2019-11-142-0/+40
| | | | | | Thanks to Marek Kurdej for the patch. Differential Revision: https://reviews.llvm.org/D70221
* [libc++][P0980] Marked member functions move/copy/assign of char_traits ↵Michael Park2019-11-1115-15/+180
| | | | | | | | | | | | | | constexpr. Reviewers: ldionne, EricWF, mclow.lists Reviewed By: ldionne Subscribers: christof, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D68840
* [libc++] Fix potential OOB in poisson_distributionLouis Dionne2019-11-072-1/+74
| | | | | See details in the original Chromium bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=994957
* [libc++] Fixed copy/copy_n/copy_backward for compilers that do not support ↵Louis Dionne2019-11-073-3/+3
| | | | | | is_constant_evaluated. Differential Revision: https://reviews.llvm.org/D69940
* [libc++] Fix some constexpr tests broken by D68837Louis Dionne2019-11-074-4/+4
| | | | This doesn't fix all the issues with D68837
* [libc++][P0202] Marked algorithms copy/copy_n/copy_if/copy_backward constexprLouis Dionne2019-11-064-181/+164
| | | | | | Thanks to Michael Park for the patch. Differential Revision: https://reviews.llvm.org/D68837
* [libc++] Add test and remove workaround for PR13592Louis Dionne2019-10-301-3/+9
| | | | | | | | PR13592 was caused by a problem in how to compiler implemented the __is_convertible_to intrinsic. That problem, reported as PR13591, was fixed back in 2012. We don't support such old versions of Clang anyway, so we don't need the library workaround that had been added to solve PR13592 (while waiting for the compiler fix).
* PR43764: Qualify a couple of calls to forward_as_tuple to be ADL-resilient.David Blaikie2019-10-281-0/+16
|
* [libcxx][NFC] Strip trailing whitespace, fix typo.Stephan T. Lavavej2019-10-2313-23/+23
|
* [NFC] Strip trailing whitespace from libc++Louis Dionne2019-10-2382-171/+171
|
* [libc++][NFC] Remove excess trailing newlines from most filesCasey Carter2019-10-2320-20/+0
| | | | Testing git commit access.
* [libcxx][test][NFC] Fix comment typos.Stephan T. Lavavej2019-10-2223-29/+29
| | | | (Testing git commit access.)
* P1152R4: Fix deprecation warnings in libc++ testsuite and in uses of ↵Richard Smith2019-10-191-0/+5
| | | | | | | | | | | | | | | | is_invocable that would internally conjure up a deprecated function type. Summary: The implementation of P1152R4 in Clang has resulted in some deprecation warnings appearing in the libc++ and libc++abi test suite. Fix or suppress these warnings. Reviewers: mclow.lists, EricWF Subscribers: christof, ldionne, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D68879 llvm-svn: 375307
* [libc++][test] Silence more warnings in variant testsCasey Carter2019-10-144-4/+4
| | | | | | More cases of signed-to-unsigned conversion warnings that missed the train for d2623522. llvm-svn: 374778
* [libc++][test] std::variant test cleanupCasey Carter2019-10-136-5/+7
| | | | | | | | * Add the conventional `return 0` to `main` in `variant.assign/conv.pass.cpp` and `variant.ctor/conv.pass.cpp` * Fix some MSVC signed-to-unsigned conversion warnings by replacing `int` literarls with `unsigned int` literals llvm-svn: 374723
* [libc++][test] Silence MSVC warning in std::optional testCasey Carter2019-10-121-1/+1
| | | | | | `make_optional<string>(4, 'X')` passes `4` (an `int`) as the first argument to `string`'s `(size_t, charT)` constructor, triggering a signed/unsigned mismatch warning when compiling with MSVC at `/W4`. The incredibly simple fix is to instead use an unsigned literal (`4u`). llvm-svn: 374684
* [libc++][test] Miscellaneous MSVC cleanupsCasey Carter2019-10-098-71/+71
| | | | | | | | | | | | * Silence unused-local-typedef warnings: `map.cons/assign_initializer_list.pass.cpp` (and the `set.cons` variant) uses a local typedef only within `LIBCPP_ASSERT`s, so clang diagnoses it as unused when testing non-libc++. * Add missing include: `c.math/abs.pass.cpp` uses `std::numeric_limits` but failed to `#include <limits>`. * Don't test non-type: A "recent" change to `meta.trans.other/underlying_type.pass.cpp` unconditionally tests the type `F` which is conditionally defined. * Use `hash<long long>` instead of `hash<short>` with `int` in `unordered_meow` deduction guide tests to avoid truncation warnings. * Convert `3.14` explicitly in `midpoint.float.pass` since MSVC incorrectly diagnoses `float meow = 3.14;` as truncating. Differential Revision: https://reviews.llvm.org/D68681 llvm-svn: 374248
* [libc++] Take 2: Implement LWG 3158Louis Dionne2019-09-272-1/+34
| | | | | | | | | | | | | | | | | | | | | Summary: LWG 3158 marks the allocator_arg_t constructor of std::tuple as conditionnally explicit based on whether the default constructors of the tuple's members are explicitly default constructible. This was previously committed as r372778 and reverted in r372832 due to the commit breaking LLVM's build in C++14 mode. This issue has now been addressed. Reviewers: mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D65232 llvm-svn: 373092
* [libc++] Take 2: Implement LWG 2510Louis Dionne2019-09-2613-11/+284
| | | | | | | | | | | | | | | | | | | | | | | Summary: LWG2510 makes tag types like allocator_arg_t explicitly default constructible instead of implicitly default constructible. It also makes the constructors for std::pair and std::tuple conditionally explicit based on the explicit-ness of the default constructibility for the pair/tuple's elements. This was previously committed as r372777 and reverted in r372832 due to the commit breaking LLVM's build in C++14 mode. This issue has now been addressed. Reviewers: mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D65161 llvm-svn: 372983
* [libcxx] Do not implicitly #include assert.hDavid Zarzycki2019-09-265-2/+7
| | | | | | | | | Users should only get the assert() macros if they explicitly include them. Found after switching from the GNU C++ stdlib to the LLVM C++ stdlib. llvm-svn: 372963
* [libc++] Purge mentions of GCC 4 from the test suiteLouis Dionne2019-09-2518-45/+2
| | | | | | | | | We don't support GCC 4 and older according to the documentation, so we should pretend it doesn't exist. This is a re-application of r372787. llvm-svn: 372916
* Add forward declaration of operator<< in <string_view> as required.Eric Fiselier2019-09-251-0/+26
| | | | | | | | This declaration was previously missing despite appearing in the synopsis. Users are still required to include <ostream> to get the definition of the streaming operator. llvm-svn: 372909
* Add a missing default parameter to regex::assign. This is LWG3296; reviewed ↵Marshall Clow2019-09-251-0/+10
| | | | | | as https://reviews.llvm.org/D67944 llvm-svn: 372896
* Revert r372777: [libc++] Implement LWG 2510 and its follow-upsIlya Biryukov2019-09-2532-309/+56
| | | | | | | | | | | | This also reverts: - r372778: [libc++] Implement LWG 3158 - r372782: [libc++] Try fixing tests that fail on GCC 5 and older - r372787: Purge mentions of GCC 4 from the test suite Reason: the change breaks compilation of LLVM with libc++, for details see http://lists.llvm.org/pipermail/libcxx-dev/2019-September/000599.html llvm-svn: 372832
* [libc++] Purge mentions of GCC 4 from the test suiteLouis Dionne2019-09-2424-51/+8
| | | | | | | We don't support GCC 4 and older according to the documentation, so we should pretend it doesn't exist. llvm-svn: 372787
* [libc++] Try fixing tests that fail on GCC 5 and olderLouis Dionne2019-09-246-1/+24
| | | | llvm-svn: 372782
* [libc++] Remove C++03 variadics in shared_ptrZoe Carver2019-09-242-122/+79
| | | | | | | | | | | | | | Summary: As suggested by @ldionne in D66178, this patch removes C++03 variadics //only//. Following patches will apply more updates. Reviewers: ldionne, EricWF, mclow.lists Subscribers: christof, dexonsmith, libcxx-commits, ldionne Tags: #libc Differential Revision: https://reviews.llvm.org/D67675 llvm-svn: 372780
* [libc++] Implement LWG 3158Louis Dionne2019-09-242-1/+34
| | | | | | | | | | | | | | | | | Summary: LWG 3158 marks the allocator_arg_t constructor of std::tuple as conditionnally explicit based on whether the default constructors of the tuple's members are explicitly default constructible. Reviewers: EricWF, mclow.lists Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D65232 llvm-svn: 372778
* [libc++] Implement LWG 2510Louis Dionne2019-09-2413-10/+250
| | | | | | | | | | | | | | | | | | | Summary: LWG2510 makes tag types like allocator_arg_t explicitly default constructible instead of implicitly default constructible. It also makes the constructors for std::pair and std::tuple conditionally explicit based on the explicit-ness of the default constructibility for the pair/tuple's elements. Reviewers: mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D65161 llvm-svn: 372777
* [libc++] Mark CTAD tests as not failing on AppleClang 10.0.1Louis Dionne2019-09-238-8/+8
| | | | | | They do fail on AppleClang 10.0.0, but not AppleClang 10.0.1 llvm-svn: 372632
* [libc++] Mark iostreams test as XFAIL on older macOSesLouis Dionne2019-09-231-0/+12
| | | | llvm-svn: 372620
* Revert "Revert "Implement std::condition_variable via ↵Dan Albert2019-09-181-11/+22
| | | | | | | | | | pthread_cond_clockwait() where available"" With the fix for non-Linux. This reverts commit c1c519d2f1a66dd2eeaa4c321d8d7b50f623eb71. llvm-svn: 372242
* Revert "Implement std::condition_variable via pthread_cond_clockwait() where ↵Dan Albert2019-09-161-22/+11
| | | | | | | | available" This reverts commit 5e37d7f9ff257ec62d733d3d94b11f03e0fe51ca. llvm-svn: 372034
* Implement std::condition_variable via pthread_cond_clockwait() where availableDan Albert2019-09-161-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::condition_variable is currently implemented via pthread_cond_timedwait() on systems that use pthread. This is problematic, since that function waits by default on CLOCK_REALTIME and libc++ does not provide any mechanism to change from this default. Due to this, regardless of if condition_variable::wait_until() is called with a chrono::system_clock or chrono::steady_clock parameter, condition_variable::wait_until() will wait using CLOCK_REALTIME. This is not accurate to the C++ standard as calling condition_variable::wait_until() with a chrono::steady_clock parameter should use CLOCK_MONOTONIC. This is particularly problematic because CLOCK_REALTIME is a bad choice as it is subject to discontinuous time adjustments, that may cause condition_variable::wait_until() to immediately timeout or wait indefinitely. This change fixes this issue with a new POSIX function, pthread_cond_clockwait() proposed on http://austingroupbugs.net/view.php?id=1216. The new function is similar to pthread_cond_timedwait() with the addition of a clock parameter that allows it to wait using either CLOCK_REALTIME or CLOCK_MONOTONIC, thus allowing condition_variable::wait_until() to wait using CLOCK_REALTIME for chrono::system_clock and CLOCK_MONOTONIC for chrono::steady_clock. pthread_cond_clockwait() is implemented in glibc (2.30 and later) and Android's bionic (Android API version 30 and later). This change additionally makes wait_for() and wait_until() with clocks other than chrono::system_clock use CLOCK_MONOTONIC.<Paste> llvm-svn: 372016
* Fix various test failures with GCCEric Fiselier2019-09-132-3/+7
| | | | llvm-svn: 371880
* Fix failing negative compilation test for some versions of ClangEric Fiselier2019-09-131-0/+1
| | | | llvm-svn: 371874
* Recommit r370502: Make `vector` unconditionally move elements whenEric Fiselier2019-09-132-45/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exceptions are disabled. The patch was reverted due to some confusion about non-movable types. ie types that explicitly delete their move constructors. However, such types do not meet the requirement for `MoveConstructible`, which is required by `std::vector`: Summary: `std::vector<T>` is free choose between using copy or move operations when it needs to resize. The standard only candidates that the correct exception safety guarantees are provided. When exceptions are disabled these guarantees are trivially satisfied. Meaning vector is free to optimize it's implementation by moving instead of copying. This patch makes `std::vector` unconditionally move elements when exceptions are disabled. This optimization is conforming according to the current standard wording. There are concerns that moving in `-fno-noexceptions`mode will be a surprise to users. For example, a user may be surprised to find their code is slower with exceptions enabled than it is disabled. I'm sympathetic to this surprised, but I don't think it should block this optimization. Reviewers: mclow.lists, ldionne, rsmith Reviewed By: ldionne Subscribers: zoecarver, christof, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D62228 llvm-svn: 371867
* Only initialize the streams cout/wcout/cerr/wcerr etc once, rather than any ↵Marshall Clow2019-09-131-0/+32
| | | | | | time Init::Init is called. Fixes PR#43300 llvm-svn: 371864
* [libc++] Add a test for resizing of a vector with copy-only elementsLouis Dionne2019-09-051-0/+45
| | | | | | See https://reviews.llvm.org/D62228#1658620 llvm-svn: 371067
* [libc++] Add yet another test for inverted character classesLouis Dionne2019-08-271-0/+3
| | | | | | | | This was reported as part of a bug report that ended up being a duplicate for r340609, but I'm adding the test case since it's ever so slightly different from what we had before. llvm-svn: 370109
OpenPOWER on IntegriCloud