summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/function.objects
Commit message (Collapse)AuthorAgeFilesLines
...
* Enable the -Wsign-compare warning to better support MSVCEric Fiselier2016-12-112-4/+4
| | | | llvm-svn: 289363
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-082-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | loss of data", part 7/7. test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp Add static_cast<char> because basic_istream::get() returns int_type (N4606 27.7.2.3 [istream.unformatted]/4). test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp Add static_cast<char> because toupper() returns int (C11 7.4.2.2/1). test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp This test is intentionally writing doubles to ostream_iterator<int>. It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing for MSVC. test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp Given `extern float zero;`, the expression `1./zero` has type double, which emits a truncation warning when being passed to test<float>() taking float. The fix is to say `1.f/zero` which has type float. test/std/numerics/complex.number/cmplx.over/arg.pass.cpp test/std/numerics/complex.number/cmplx.over/norm.pass.cpp These tests were constructing std::complex<double>(x, 0), emitting truncation warnings when x is long long. Saying static_cast<double>(x) avoids this. test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp This was using `int s` to construct and seed a linear_congruential_engine<T, stuff>, where T is unsigned short/unsigned int/unsigned long/unsigned long long. That emits a truncation warning in the unsigned short case. Because the range [0, 20) is tiny and we aren't doing anything else with the index, we can just iterate with `T s`. test/std/re/re.traits/value.pass.cpp regex_traits<wchar_t>::value()'s first parameter is wchar_t (N4606 28.7 [re.traits]/13). This loop is using int to iterate through ['g', 0xFFFF), emitting a truncation warning from int to wchar_t (which is 16-bit for some of us). Because the bound is exclusive, we can just iterate with wchar_t. test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp This test is a little strange. It's trying to verify that basic_string's (InIt, InIt) range constructor isn't confused by "N copies of C" when N and C have the same integral type. To do this, it was testing (100, 65), but that eventually emits truncation warnings from int to char. There's a simple way to avoid this - passing (static_cast<char>(100), static_cast<char>(65)) also exercises the disambiguation. (And 100 is representable even when char has a signed range.) test/std/strings/string.view/string.view.hash/string_view.pass.cpp Add static_cast<char_type> because `'0' + i` has type int. test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp What's more horrible than nested bind()? pow() overloads! This operator()(T a, T b) was assuming that std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 26.9.1 [cmath.syn]/2 says that pow(int, int) returns double, so this was truncating double to int. Adding static_cast<T> silences this. test/std/utilities/function.objects/unord.hash/integral.pass.cpp This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` but that's truncating when T is short. (And super truncating when T is bool.) Adding static_cast<T> silences this. test/std/utilities/utility/exchange/exchange.pass.cpp First, this was exchanging 67.2 into an int, but that's inherently truncating. Changing this to static_cast<short>(67) avoids the truncation while preserving the "what if T and U are different" test coverage. Second, this was exchanging {} with the explicit type float into an int, and that's also inherently truncating. Specifying short is just as good. test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp Add static_cast<short>. Note that this affects template argument deduction for make_pair(), better fulfilling the test's intent. For example, this was saying `typedef std::pair<int, short> P1; P1 p1 = std::make_pair(3, 4);` but that was asking make_pair() to return pair<int, int>, which was then being converted to pair<int, short>. (pair's converting constructors are tested elsewhere.) Now, std::make_pair(3, static_cast<short>(4)) actually returns pair<int, short>. (There's still a conversion from pair<nullptr_t, short> to pair<unique_ptr<int>, short>.) Fixes D27544. llvm-svn: 289111
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-085-10/+10
| | | | | | | | | | | | | loss of data", part 2/7. These tests for some guy's transparent operator functors were needlessly truncating their double results to int. Preserving the doubleness makes compilers happier. I'm following existing practice by adding an "// exact in binary" comment when the result isn't a whole number. (The changes from 6 to 6.0 and so forth are stylistic, not critical.) Fixes D27539. llvm-svn: 289106
* [libcxx] [test] D26815: Fix an assumption about the state of moved-from ↵Stephan T. Lavavej2016-11-181-2/+2
| | | | | | | | | | | std::functions. The Standard doesn't provide any guarantees beyond "valid but unspecified" for moved-from std::functions. libcxx moves from small targets and leaves them there, while MSVC's STL empties out the source. Mark these assertions as libcxx-specific. llvm-svn: 287382
* [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER.Stephan T. Lavavej2016-11-0412-12/+36
| | | | | | | | | | | This replaces every occurrence of _LIBCPP_STD_VER in the tests with TEST_STD_VER. Additionally, for every affected file, #include "test_macros.h" is being added explicitly if it wasn't already there. https://reviews.llvm.org/D26294 llvm-svn: 286007
* Update LWG 2767 and add test caseEric Fiselier2016-10-161-0/+14
| | | | llvm-svn: 284324
* Add void_t and invoke feature test macrosEric Fiselier2016-10-141-0/+39
| | | | llvm-svn: 284209
* Implement http://wg21.link/p0302r1: Removing Allocator Support in ↵Marshall Clow2016-10-1312-0/+210
| | | | | | std::function. These functions never worked, and as far as I know, no one ever called them. llvm-svn: 284164
* Remove use of _VSTD::__invoke in the not_fn testsEric Fiselier2016-10-121-1/+4
| | | | llvm-svn: 283991
* Add tests to check that swap(std::function, std::function) is noexcept. This ↵Marshall Clow2016-10-101-1/+14
| | | | | | is LWG#2062, but we already do this. No changes to the library, just adding tests. llvm-svn: 283780
* Remove all instances of _LIBCPP_HAS_NO_RVALUE_REFERENCES from test/std/utilitiesEric Fiselier2016-10-012-4/+7
| | | | llvm-svn: 283032
* Add missing _v traits. is_bind_expression_v, is_placeholder_v and ↵Marshall Clow2016-09-222-0/+8
| | | | | | uses_allocator_v llvm-svn: 282126
* Implement LWG 2148: Make non-enum default hash specialization well-formedEric Fiselier2016-08-102-5/+40
| | | | | | | | | | | | | | | | | Summary: This patch removes the static_assert for non-enum types in the primary hash template. Instead non-enum types create a hash<T> specialization that is not constructible nor callable. See also: * http://cplusplus.github.io/LWG/lwg-active.html#2543 * https://llvm.org/bugs/show_bug.cgi?id=28917 Reviewers: mclow.lists, EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D23331 llvm-svn: 278300
* Guard libc++ specific tests SFINAE on std::bind's call operator. Patch from ↵Eric Fiselier2016-07-241-3/+5
| | | | | | STL@microsoft.com llvm-svn: 276576
* Implement LWG 2393. Check for LValue-callability.Eric Fiselier2016-07-243-0/+65
| | | | llvm-svn: 276546
* Fix inheriting constructor test for std::function.Eric Fiselier2016-07-201-4/+7
| | | | | | | The test I originally checked in only worked with ToT Clang. This patch updates the test so that it works as far back as 3.5. llvm-svn: 276093
* Add missed test in r276090.Eric Fiselier2016-07-201-0/+23
| | | | llvm-svn: 276091
* Implement P0358r1. Fixes for not_fn.Eric Fiselier2016-06-271-28/+69
| | | | llvm-svn: 273837
* Implement LWG 2488 - Make the placeholders constexpr.Eric Fiselier2016-06-261-0/+28
| | | | | | | | | | | | | | | | | | | This patch makes the bind placeholders in std::placeholders both (1) const and (2) constexpr (See below). This is technically a breaking change for any code using the placeholders outside of std::bind and depending on them being non-const. However I don't think this will break any real world code. (1) Previously the placeholders were non-const extern globals in all dialects. This patch changes these extern globals to be const in all dialects. Since the cv-qualifiers don't participate in name mangling for globals this is an ABI compatible change. (2) Make the placeholders constexpr in C++11 and beyond. Although LWG 2488 only applies to C++17 I don't see any reason not to backport this change. llvm-svn: 273824
* Move remaining _LIBCPP_VERSION tests into test/libcxxEric Fiselier2016-06-221-20/+0
| | | | llvm-svn: 273367
* Don't use C++17 terse static assert. Patch from STL@microsoft.comEric Fiselier2016-06-222-34/+34
| | | | llvm-svn: 273353
* Suppress unused warnings in std::invoke tests.Eric Fiselier2016-06-221-4/+4
| | | | llvm-svn: 273348
* Guard libc++ assumption about identity hashing in test. Patch from ↵Eric Fiselier2016-06-221-3/+7
| | | | | | STL@microsoft.com llvm-svn: 273345
* Replace __cplusplus comparisons and dialect __has_feature checks with ↵Eric Fiselier2016-06-142-2/+6
| | | | | | | | | TEST_STD_VER. This is a huge cleanup that helps make the libc++ test suite more portable. Patch from STL@microsoft.com. Thanks STL! llvm-svn: 272716
* Prevent truncation warning. Patch from STL@microsoft.comEric Fiselier2016-06-141-1/+1
| | | | llvm-svn: 272621
* Add not_fn test for throwing operator!Eric Fiselier2016-06-021-0/+8
| | | | llvm-svn: 271502
* Mark LWG issue 2545 as complete. Add extra testsEric Fiselier2016-06-022-0/+132
| | | | llvm-svn: 271489
* Mark LWG issue 2450 as complete.Eric Fiselier2016-06-027-6/+80
| | | | llvm-svn: 271473
* Add C++17 std::not_fn negator.Eric Fiselier2016-06-022-0/+578
| | | | | | | | | | | | | | | Summary: Exactly what it sounds like. I plan to commit this in a couple of days assuming no objections. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20799 llvm-svn: 271464
* Remove trailing whitespace in test suite. Approved by Marshall Clow.Eric Fiselier2016-06-017-8/+8
| | | | llvm-svn: 271435
* Mark LWG issue 2565 as complete. Update the tests to check it.Eric Fiselier2016-05-312-28/+100
| | | | llvm-svn: 271238
* [libcxx] Improve tests to use the UNSUPPORTED lit directiveAsiri Rathnayake2016-05-285-25/+15
| | | | | | | | | | | | | | | | | | | Quite a few libcxx tests seem to follow the format: #if _LIBCPP_STD_VER > X // Do test. #else // Empty test. #endif We should instead use the UNSUPPORTED lit directive to exclude the test on earlier C++ standards. This gives us a more accurate number of test passes for those standards and avoids unnecessary conflicts with other lit directives on the same tests. Reviewers: bcraig, ericwf, mclow.lists Differential revision: http://reviews.llvm.org/D20730 llvm-svn: 271108
* Move INVOKE tests into test/libcxx sub-tree.Eric Fiselier2016-04-296-1419/+16
| | | | | | | | | Testing the concrete implementation of INVOKE means calling the implementation specific names `__invoke` and `__invoke_constexpr`. For this reason the test are non-standard. For this reason it's best if the tests live outside of the `test/std` directory. llvm-svn: 267973
* Remove names of unreferenced parameters. Patch from STL@microsoft.comEric Fiselier2016-04-282-3/+3
| | | | llvm-svn: 267852
* Add 'is_callable' and 'is_nothrow_callable' traits and cleanup INVOKE.Eric Fiselier2016-04-204-55/+200
| | | | | | | | | | | | The primary purpose of this patch is to add the 'is_callable' traits. Since 'is_nothrow_callable' required making 'INVOKE' conditionally noexcept I also took this oppertunity to implement a constexpr version of INVOKE. This fixes 'std::experimental::apply' which required constexpr 'INVOKE support'. This patch will be followed up with some cleanup. Primarly removing most of "__member_function_traits" since it's no longer used by INVOKE (in C++11 at least). llvm-svn: 266836
* Implement LWG issue 2219 - support reference_wrapper in INVOKEEric Fiselier2016-04-185-35/+201
| | | | llvm-svn: 266590
* Add hash specializations for __int128_t. Fixes LWG issue 2119Eric Fiselier2016-04-181-3/+8
| | | | llvm-svn: 266587
* Implement LWG#2385; remove the allocator-aware std::function::assign call. ↵Marshall Clow2016-01-251-0/+4
| | | | | | It was useless, and didn't actually *do anything* with the allocator. Now it's gone. On the off chance that someone is mistakenly calling it, it's only gone in C++1z llvm-svn: 258697
* Mark some test XFAIL for GCC 4.9 due to missing is_trivial* traitsEric Fiselier2016-01-201-0/+3
| | | | llvm-svn: 258287
* Add missing license headersEric Fiselier2016-01-192-0/+18
| | | | llvm-svn: 258196
* One more missing std:: qualification from JonathanMarshall Clow2016-01-121-1/+2
| | | | llvm-svn: 257506
* Add tests for the extended integer types - as required by LWG#2119Marshall Clow2015-11-171-0/+40
| | | | llvm-svn: 253376
* Fix typo I just introduced.Marshall Clow2015-11-101-1/+1
| | | | llvm-svn: 252614
* Explicitly #include <utility> so that we get std::move. Thanks to Walter for ↵Marshall Clow2015-11-101-0/+1
| | | | | | the bug report. llvm-svn: 252610
* Fix LWG#2489: mem_fn() should be noexceptMarshall Clow2015-10-251-0/+3
| | | | llvm-svn: 251257
* [libcxx] Rewrite C++03 __invoke.Eric Fiselier2015-08-262-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch rewrites the C++03 `__invoke` and related meta-programming. There are a number of major changes. `__invoke` in C++03 now has a fallback overload for when the invoke expression is ill-formed (similar to C++11). This means that the `__invoke_return` traits will return `__nat` when `__invoke(...)` is ill formed. This would previously cause a compile error. Bullets 1-4 of `__invoke` have been rewritten. In the old version `__invoke` had 32 overloads for bullets 1 and 2, one for each possible cv-qualified function signature with arities 0-3. 64 overloads would be needed to support member functions with varargs. Currently these overloads were fundamentally broken. An example overload looked like: ``` template <class Rp, class Tp, class T1, class A0> Rp __invoke(Rp (Tp::*pm)(A0) const, T1&, A0&) ``` Because `A0` appeared in two different deducible contexts it would have to deduce to be an exact match or the overload would be rejected. This is made even worse because `A0` appears without a reference qualifier in the member function signature and with a reference qualifier as an `__invoke` parameter. This means that only member functions that took all of their arguments by value could be matched. One possible fix would be to make the second occurrence of `A0` appear in a non-deducible context. This way any type convertible to `A0` could be passed as the first parameter. The benefit of this approach is that the signature of the member function enforces the arity and types taken by the `__invoke` signature it generates. However nothing in the `INVOKE` specification requires this behavior. My solution is to use a `__invoke_enable_if<PM_Type, Tp>` metafunction to selectively enable the `__invoke` overloads for bullets 1, 2, 3 and 4. It uses `__member_function_traits` to inspect and extract the return type and class type of the pointer to member. Using `__member_function_traits` to inspect `PM_Type` also allows us to reduce the number of `__invoke` overloads from 32 to 8 and add varargs support at the same time. Because `__invoke_enable_if` knows the exact return type of `__invoke` for bullets 1-4 we no longer need to use `decltype(__invoke(...))` to compute the return type in the `__invoke_return*` traits. This will reduce the problems caused by `#define decltype(X) __typeof__(X)` in C++03. Tests for this change have already been committed. All tests in `test/std/utilities/function.objects` now pass in C++03, previously there were 20 failures. Reviewers: K-ballo, howard.hinnant, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11553 llvm-svn: 246068
* [libcxx] Fix PR23589: std::function doesn't recognize null pointer to ↵Eric Fiselier2015-08-181-0/+247
| | | | | | | | | | | | | | | | | | | | varargs function. Summary: This patch fixes __not_null's detection of nullptr by breaking it down into 4 cases. 1. `__not_null(Tp const&)`: Default case. Tp is not null. 2. `__not_null(Tp* __ptr);` Case for pointers to functions. 3. `__not_null(_Ret _Class::* __ptr);` Case for pointers to members. 4. `__not_null(function<Tp> const&);`: Cases for other std::functions. Reviewers: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11111 llvm-svn: 245335
* Checking more __invoke tests.Eric Fiselier2015-07-284-0/+1126
| | | | | | | Before I start trying to fix __invoke in C++03 it needs better test coverage. This patch adds a large amount of tests for __invoke. llvm-svn: 243366
* Cleanup <__functional_03>Eric Fiselier2015-07-229-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | <__functional_03> provides the C++03 definitions for std::memfun and std::function. However the interaction between <functional> and <__functional_03> is ugly and duplicates code needlessly. This patch cleans up how the two headers work together. The major changes are: - Provide placeholders, is_bind_expression and is_placeholder in <functional> for both C++03 and C++11. - Provide bad_function_call, function fwd decl, __maybe_derive_from_unary_function and __maybe_derive_from_binary_function in <functional> for both C++03 and C++11. - Move the <__functional_03> include to the bottom of <functional>. This makes it easier to see how <__functional_03> interacts with <functional> - Remove a commented out implementation of bind in C++03. It's never going to get implemented. - Mark almost all std::bind tests as unsupported in C++03. std::is_placeholder works in C++03 and C++11. std::is_bind_expression is provided in C++03 but always returns false. llvm-svn: 242870
* Cleanup tests that fail in C++1z and with Clang 3.8Eric Fiselier2015-07-177-369/+242
| | | | llvm-svn: 242581
OpenPOWER on IntegriCloud