summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
Commit message (Collapse)AuthorAgeFilesLines
* Fix most GCC test failures.Eric Fiselier2018-01-186-15/+61
| | | | | | | | | | | | | | | | | | | | | | | This patch fixes almost all currently failing tests when using GCC ToT. The specific changes are: (A) Workaround gcc.gnu.org/PR83921 which rejects variables w/o initializers in constexpr contexts -- even when the variable is an empty class. This bug has been worked around at all callsites by adding an initializer. Additionally a new test, constexpr_init.pass.cpp, has been added to test that Clang doesn't suffer from these bugs. (B) Fix streambuf.assign/swap.pass.cpp. This test was never actually calling the swap method as intended. In fact, the swap function it intended to call was ill-formed when instantiated. GCC diagnosed this ill-formedness w/o needing an instantiation. (C) size_delete11.pass.cpp was fixed by adding c++2a to the list of unsupported dialects. llvm-svn: 322810
* Fix nodiscard failure tests on compilers w/o -verify.Eric Fiselier2018-01-171-1/+1
| | | | | | | | | | | | | Previously .fail.cpp tests for nodiscard were run with -Wunused-result being a warning, not an error, when the compiler didn't support -verify. When -verify isn't enabled this change judiciously adds -Werror=unused-result when to only the failure tests containing the // expected-error string for nodiscard. As a drive-by change, this patch also adds a missing // UNSUPPORTED: c++2a to a test which was only supposed to run in C++ <= 11. llvm-svn: 322776
* More constexpr algorithms from P0202. search/search_nMarshall Clow2018-01-164-4/+79
| | | | llvm-svn: 322566
* More constexpr algorithms from P0202: lower_bound, upper_bound, equal_range, ↵Marshall Clow2018-01-1610-22/+155
| | | | | | binary_search llvm-svn: 322529
* Actually CALL the constexpr tests.Marshall Clow2018-01-162-0/+8
| | | | llvm-svn: 322528
* More constexpr (re P0202) - equal and mismatchMarshall Clow2018-01-164-4/+146
| | | | llvm-svn: 322527
* Fix constexpr failure on C++11-based buildbots.Marshall Clow2018-01-151-1/+1
| | | | llvm-svn: 322507
* More constexpr from P0202. count and count_if. Also fix a comment that ↵Marshall Clow2018-01-152-4/+33
| | | | | | Morwenn noted. llvm-svn: 322506
* Some of the tests from earlier today had 'int' as the return type when it ↵Marshall Clow2018-01-1515-15/+15
| | | | | | should have been 'bool'. Fix that. It doesn't change the behavior of any of the tests, but it's more accurate. llvm-svn: 322505
* More P0202 constexpr-ifying. All the find_XXX algorithms in this commit.Marshall Clow2018-01-159-14/+192
| | | | llvm-svn: 322504
* partition_point gets the P0202 treatmentMarshall Clow2018-01-153-4/+21
| | | | llvm-svn: 322493
* More constexpr algorithms from P0202. any_of/all_of/none_of.Marshall Clow2018-01-153-3/+48
| | | | llvm-svn: 322492
* First part of P0202: Adding constexpr modifiers to functions in <algorithm> ↵Marshall Clow2018-01-1511-8/+173
| | | | | | and <utility>. This commit is all the is_XXX algorithms. llvm-svn: 322489
* Add error code handling to remove_all testEkaterina Vaartis2018-01-121-1/+1
| | | | | | As mentioned by EricWF in revision D41830 llvm-svn: 322351
* [libcxx] Make std::basic_istream::get 0-terminate input array in case of error.Volodymyr Sapsai2018-01-112-0/+124
| | | | | | | | | | | | | | | | | | | It covers the cases when the sentry object returns false and when an exception was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p9: [...] In any case, if n is greater than zero it then stores a null character into the next successive location of the array. rdar://problem/35566567 Reviewers: EricWF, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40677 llvm-svn: 322326
* Make std::experimental::filesystem::remove and remove_all return false or 0 ↵Ekaterina Vaartis2018-01-112-3/+27
| | | | | | | | if the file doesn't exist Differential Revision: https://reviews.llvm.org/D41830 llvm-svn: 322293
* Fix misspelled macro name - thanks to andrew@ispras.ru for the catchMarshall Clow2018-01-101-1/+1
| | | | llvm-svn: 322196
* [libcxx] [test] Improve MSVC portability.Stephan T. Lavavej2018-01-102-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | test/support/msvc_stdlib_force_include.hpp When testing MSVC's STL with C1XX, simulate a couple more compiler feature-test macros. When testing MSVC's STL, simulate a few library feature-test macros. test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp The vector_size attribute is a non-Standard extension that's supported by Clang and GCC, but not C1XX. Therefore, guard this with `__has_attribute(vector_size)`. Additionally, while these tests pass when MSVC's STL is compiled with Clang, I don't consider this to be a supported scenario for our library, so also guard this with defined(_LIBCPP_VERSION). test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp N4713 23.14.10 [func.not_fn]/1 depicts only `call_wrapper(call_wrapper&&) = default;` and `call_wrapper(const call_wrapper&) = default;`. According to 15.8.2 [class.copy.assign]/2 and /4, this makes call_wrapper non-assignable. Therefore, guard the assignability tests as libc++ specific. Add a (void) cast to tolerate not_fn() being marked as nodiscard. Fixes D41213. llvm-svn: 322144
* Apparently 'C++14' is different than 'c++14'Marshall Clow2018-01-081-1/+1
| | | | llvm-svn: 322034
* Change add_ten to add_one to avoid triggering ubsan integer overflow.Billy Robert O'Neal III2018-01-083-67/+67
| | | | llvm-svn: 322021
* Add the C++17 extensions to std::search. Include the default searcher, but ↵Marshall Clow2018-01-0812-0/+1292
| | | | | | not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked to XFAIL. The other searchers will follow soon llvm-svn: 322019
* Add pre-C++11 is_constructible wrappers for 3 argumentsDimitry Andric2018-01-071-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: After rL319736 for D28253 (which fixes PR28929), gcc cannot compile `<memory>` anymore in pre-C+11 modes, complaining: ``` In file included from /usr/include/c++/v1/memory:648:0, from test.cpp:1: /usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::make_shared(_A0&, _A1&, _A2&)': /usr/include/c++/v1/memory:4365:5: error: wrong number of template arguments (4, should be at least 1) static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" ); ^ In file included from /usr/include/c++/v1/memory:649:0, from test.cpp:1: /usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible' struct _LIBCPP_TEMPLATE_VIS is_constructible ^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/v1/memory:648:0, from test.cpp:1: /usr/include/c++/v1/memory:4365:5: error: template argument 1 is invalid static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" ); ^ /usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::allocate_shared(const _Alloc&, _A0&, _A1&, _A2&)': /usr/include/c++/v1/memory:4444:5: error: wrong number of template arguments (4, should be at least 1) static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" ); ^ In file included from /usr/include/c++/v1/memory:649:0, from test.cpp:1: /usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible' struct _LIBCPP_TEMPLATE_VIS is_constructible ^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/v1/memory:648:0, from test.cpp:1: /usr/include/c++/v1/memory:4444:5: error: template argument 1 is invalid static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" ); ^ ``` This is also reported in https://bugs.freebsd.org/224946 (FreeBSD is apparently one of the very few projects that regularly builds programs against libc++ with gcc). The reason is that the static assertions are invoking `is_constructible` with three arguments, while gcc does not have the built-in `is_constructible` feature, and the pre-C++11 `is_constructible` wrappers in `<type_traits>` only provide up to two arguments. I have added additional wrappers for three arguments, modified the `is_constructible` entry point to take three arguments instead, and added a simple test to is_constructible.pass.cpp. Reviewers: EricWF, mclow.lists Reviewed By: EricWF Subscribers: krytarowski, cfe-commits, emaste Differential Revision: https://reviews.llvm.org/D41805 llvm-svn: 321963
* Add casts to prevent narrowing warnings.Billy Robert O'Neal III2018-01-063-6/+6
| | | | llvm-svn: 321923
* [libcxx] [test] Remove nonstandard things and resolve warnings in Xxx_scan testsBilly Robert O'Neal III2018-01-068-101/+98
| | | | | | | | | | | Reviewed as https://reviews.llvm.org/D41748 * These tests use function objects from functional, back_inserter from iterator, and equal from algorithm, so add those headers. * The use of iota targeting vector<unsigned char> with an int parameter triggers warnings on MSVC++ assigning an into a unsigned char&; so change the parameter to unsigned char with a static_cast. * Avoid naming unary_function in identity here as that is removed in '17. (This also fixes naming _VSTD, _NOEXCEPT_, and other libcxx-isms) * Change the predicate in the transform tests to add_ten so that problems with multiple application are caught. llvm-svn: 321922
* Move + and * operators of MoveOnly into MoveOnly.h.Billy Robert O'Neal III2018-01-051-10/+0
| | | | llvm-svn: 321852
* Fix incorrect handling of move-only types in transform_reduce iter iter iter ↵Billy Robert O'Neal III2018-01-051-0/+22
| | | | | | init, and add test. llvm-svn: 321851
* Add move-only types test to transform_reduce iter iter iter init op op.Billy Robert O'Neal III2018-01-051-0/+14
| | | | llvm-svn: 321849
* Add move-only types test for transform_reduce bop/uop.Billy Robert O'Neal III2018-01-051-0/+13
| | | | llvm-svn: 321848
* Fix nonstandard bits in transform_reduce_iter_iter_init_bop_uop.Billy Robert O'Neal III2018-01-051-43/+27
| | | | | | | | * _VSTD should be std. * <utility> is needed for forward. * unary_function is no longer standard (and unnecessary for this, a C++17-only test) llvm-svn: 321847
* Mark LWG2824 as complete. We already did it, but I added a test to be sureMarshall Clow2018-01-031-0/+41
| | | | llvm-svn: 321689
* Implement p0258r2: has_unique_object_representationsMarshall Clow2018-01-031-0/+104
| | | | llvm-svn: 321685
* Fix the definitions of 'reference' and 'pointer' in string_view that no one ↵Marshall Clow2017-12-201-0/+77
| | | | | | uses :-). Thanks to K-ballo for the catch. llvm-svn: 321188
* libcxx: Fix for basic_stringbuf::seekoff() after r320604.Peter Collingbourne2017-12-191-0/+24
| | | | | | | | | | | | | As a result of this change, the basic_stringbuf constructor that takes a mode ends up leaving __hm_ set to 0, causing the comparison "__hm_ - __str_.data() < __noff" in seekoff() to succeed, which caused the function to incorrectly return -1. The fix is to account for the possibility of __hm_ being 0 when computing the distance from __hm_ to the start of the string. Differential Revision: https://reviews.llvm.org/D41319 llvm-svn: 321124
* [libcxx] Fix basic_stringbuf constructorZhihao Yuan2017-12-131-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: [libcxx] Fix basic_stringbuf constructor The C++ Standard [stringbuf.cons]p1 defines the effects of the basic_stringbuf constructor that takes ios_base::openmode as follows: Effects: Constructs an object of class basic_stringbuf, initializing the base class with basic_streambuf(), and initializing mode with which. Postconditions: str() == "". The default constructor of basic_streambuf shall initialize all its pointer member objects to null pointers [streambuf.cons]p1. Currently libc++ calls "str(string_type());" in the aforementioned constructor setting basic_streambuf's pointers to a non-null value. This patch removes the call (note that the postcondition str() == "" remains valid because __str_ is default-initialized) and adds a test checking that the basic_streambuf's pointers are null after construction. Thanks Mikhail Maltsev for the patch. Reviewers: EricWF, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40707 llvm-svn: 320604
* [libcxx] [test] Fix line endings, avoid unnecessary non-ASCII.Stephan T. Lavavej2017-12-132-15/+15
| | | | | | | | | | | | | | | benchmarks/util_smartptr.bench.cpp Change CRLF to LF. test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp Consistently comment "\u20ac" as EURO SIGN, its Unicode name, instead of the actual Unicode character. test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_type.pass.cpp Avoid non-ASCII dash. Fixes D40991. llvm-svn: 320536
* [libcxx] [test] Fix MSVC warnings, null pointer deref.Stephan T. Lavavej2017-12-134-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | test/std/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp Silence MSVC warning C4244. This is expected when passing floating-point values for size. test/std/utilities/template.bitset/bitset.members/to_ullong.pass.cpp test/std/utilities/template.bitset/bitset.members/to_ulong.pass.cpp Avoid MSVC "warning C4293: '<<': shift count negative or too big, undefined behavior". MSVC sees (1ULL << N) and warns - being guarded by const bool canFit is insufficient. A small change to the code avoids the warning without the need for a pragma. Remove a spurious printf() declaration from to_ullong.pass.cpp. Change ULL to UL in to_ulong.pass.cpp. The ULL suffix was probably copy-pasted. test/std/utilities/tuple/tuple.general/ignore.pass.cpp Use LIBCPP_STATIC_ASSERT for consistency with other files. test/support/container_test_types.h Fix a null pointer dereference, found by MSVC /analyze warning C6011 "Dereferencing NULL pointer 'm_expected_args'." Fixes D41030. llvm-svn: 320535
* [libcxx] P0604, invoke_result and is_invocableZhihao Yuan2017-12-128-291/+349
| | | | | | | | | | | | | | | | | | | | Summary: Introduce a new form of `result_of` without function type encoding. Rename and split `is_callable/is_nothrow_callable` into `is_invocable/is_nothrow_invocable/is_invocable_r/is_nothrow_invocable_r` (and associated types accordingly) Change function type encoding of previous `is_callable/is_nothrow_callable` traits to conventional template type parameter lists. Reviewers: EricWF, mclow.lists, bebuch Reviewed By: EricWF, bebuch Subscribers: lichray, bebuch, cfe-commits Differential Revision: https://reviews.llvm.org/D38831 llvm-svn: 320509
* [libcxx] Define istream_iterator equality comparison operators out-of-lineRoger Ferrer Ibanez2017-12-111-0/+3
| | | | | | | | | | | | | | | | | Currently libc++ defines operator== and operator!= as friend functions in the definition of the istream_iterator class template. Such definition has a subtle difference from an out-of-line definition required by the C++ Standard: these functions can only be found by argument-dependent lookup, but not by qualified lookup. This patch changes the definition, so that it conforms to the C++ Standard and adds a check involving qualified lookup to the test suite. Patch contributed by Mikhail Maltsev. Differential Revision: https://reviews.llvm.org/D40415 llvm-svn: 320363
* [libcxx] [test] Strip trailing whitespace. NFC.Stephan T. Lavavej2017-12-075-5/+5
| | | | llvm-svn: 319994
* Land D28253 which fixes PR28929 (which we mistakenly marked as fixed before)Marshall Clow2017-12-052-0/+58
| | | | llvm-svn: 319736
* Commit tests for changes in revision 319710Marshall Clow2017-12-0410-0/+252
| | | | llvm-svn: 319711
* Ooops. I checked in a test for a bug I haven't fixed yet. Temporrarily ↵Marshall Clow2017-12-041-0/+2
| | | | | | commented it out. llvm-svn: 319693
* Implement P0457R2: 'String Prefix and Suffix Checking' for c++2aMarshall Clow2017-12-0413-0/+861
| | | | llvm-svn: 319687
* Fix PR#35948: generate_n does not accept floating point Size arguments.Marshall Clow2017-12-041-5/+18
| | | | llvm-svn: 319675
* Fix problems with r'890 when building on machines where sizeof(size_t) != ↵Marshall Clow2017-11-272-6/+3
| | | | | | sizeof(unsigned long long) and C++03 llvm-svn: 319106
* Revert commit removing allocator support from packaged_task. Will ↵Marshall Clow2017-11-272-0/+37
| | | | | | investigate further llvm-svn: 319091
* Implement LWG#2921 and LWG#2976 - removing allocator support from packaged_task.Marshall Clow2017-11-272-37/+0
| | | | llvm-svn: 319080
* Fix PR#35438 - bitset constructor does not zero unused bitsMarshall Clow2017-11-272-1/+20
| | | | llvm-svn: 319074
* Fix failure on C++03 botsMarshall Clow2017-11-272-0/+6
| | | | llvm-svn: 319042
* Implement LWG#2948: unique_ptr does not define operator<< for stream outputMarshall Clow2017-11-272-0/+60
| | | | llvm-svn: 319038
OpenPOWER on IntegriCloud