Commit Graph

110 Commits

Author SHA1 Message Date
Louis Dionne
604afd7688 [libcxx] Implement P0318: unwrap_ref_decay and unwrap_reference
Summary:
This was voted into C++20 in San Diego. Note that there was a revision
D0318R2 which did include unwrap_reference_t, but we mistakingly voted
P0318R1 into the C++20 Working Draft (which does not include
unwrap_reference_t). This patch implements D0318R2, which is what
we'll end up with in the Working Draft once this mistake has been
fixed.

Reviewers: EricWF, mclow.lists

Subscribers: christof, dexonsmith, libcxx-commits

Differential Revision: https://reviews.llvm.org/D54485

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348138 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-03 14:03:27 +00:00
Marshall Clow
3b4ca5b4af Mark P0771 as complete; we already did this - I just added tests to be sure
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347343 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-20 20:37:07 +00:00
Louis Dionne
f9b79dcfc3 [libcxx] Fix XFAIL for GCC 4.9
The XFAIL started passing since we're only testing for trivial-copyability of
reference_wrapper in C++14 and above. This commit constrains the XFAIL to
gcc-4.9 with C++14 (it would also fail on C++17 and above, but those standards
are not available with GCC 4.9).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347264 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-19 20:53:38 +00:00
Louis Dionne
22507d63b6 [libcxx] Update test of trivial copyability of reference_wrapper
N4151 is not an extension anymore, it was standardized in C++14.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347263 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-19 20:21:45 +00:00
Louis Dionne
2495dabf93 [libcxx] Fix the binder deprecation tests on Clang 5.
Tested on Docker containers with Clang 4, 5 and 6.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@342855 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-23 23:17:48 +00:00
Louis Dionne
58deb8a9c9 [libcxx] Fix buildbots on Debian
Debian build bots are running Clang 4, which apparently does not support
the "deprecated" attribute properly. Clang pretends to support the attribute,
but the attribute doesn't do anything.

(live example: https://wandbox.org/permlink/0De69aXns0t1D59r)

On a separate note, I'm not sure I understand why we're even running the
libc++ tests under Clang-4. Is this a configuration we support? I can
understand that libc++ should _build_ with Clang 4, but it's not clear
to me that new libc++ headers should be usable under older compilers
like that.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@342854 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-23 22:16:35 +00:00
Louis Dionne
13cf3b9b36 [libc++] Add deprecated attributes to many deprecated components
Summary:
These deprecation warnings are opt-in: they are only enabled when the
_LIBCXX_DEPRECATION_WARNINGS macro is defined, which is not the case
by default. Note that this is a first step in the right direction, but
I wasn't able to get an exhaustive list of all deprecated components
per standard, so there's certainly stuff that's missing. The list of
components this commit marks as deprecated is:

in C++11:
- auto_ptr, auto_ptr_ref
- binder1st, binder2nd, bind1st(), bind2nd()
- pointer_to_unary_function, pointer_to_binary_function, ptr_fun()
- mem_fun_t, mem_fun1_t, const_mem_fun_t, const_mem_fun1_t, mem_fun()
- mem_fun_ref_t, mem_fun1_ref_t, const_mem_fun_ref_t, const_mem_fun1_ref_t, mem_fun_ref()

in C++14:
- random_shuffle()

in C++17:
- unary_negate, binary_negate, not1(), not2()

<rdar://problem/18168350>

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, llvm-commits

Differential Revision: https://reviews.llvm.org/D48912

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@342843 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-23 18:35:00 +00:00
Volodymyr Sapsai
db0ba4480a [libcxx] func.wrap.func.con: Unset function before destroying anything
Be defensive against a reentrant std::function::operator=(nullptr_t), in case
the held function object has a non-trivial destructor.  Destroying the function
object in-place can lead to the destructor being called twice.

Patch by Duncan P. N. Exon Smith. C++03 support by Volodymyr Sapsai.

rdar://problem/32836603

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits, arphaman

Differential Revision: https://reviews.llvm.org/D34331


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@330885 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-25 23:38:41 +00:00
Roman Lebedev
862878bc38 [libcxx][test] Silence -Wself-assign diagnostics
Summary:
D44883 extends -Wself-assign to also work on C++ classes.
These new warnings pop up in the test suite, so they have to be silenced.

Please refer to the D45082 for disscussion on whether this is the right way to solve this.

Testing: `ninja check-libcxx check-libcxxabi` in stage-2 build.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: Quuxplusone, cfe-commits

Differential Revision: https://reviews.llvm.org/D45128

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@329490 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-07 10:36:03 +00:00
Eric Fiselier
b7f27d421f Un-XFAIL a test under new GCC version; the GCC bug has been fixed
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@328229 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-22 19:18:08 +00:00
Eric Fiselier
457d2c157b Fix most GCC test failures.
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322810 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-18 03:41:06 +00:00
Stephan T. Lavavej
4ffbed58e9 [libcxx] [test] Improve MSVC portability.
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322144 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 00:39:46 +00:00
Marshall Clow
773a3a53f9 Apparently 'C++14' is different than 'c++14'
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322034 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-08 22:16:30 +00:00
Marshall Clow
334063336b Add the C++17 extensions to std::search. Include the default searcher, but 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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322019 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-08 19:18:00 +00:00
Zhihao Yuan
e445521637 [libcxx] P0604, invoke_result and is_invocable
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@320509 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-12 18:42:04 +00:00
Eric Fiselier
f2c4a96359 Fix PR34298 - Allow std::function with an incomplete return type.
This patch fixes llvm.org/PR34298. Previously libc++ incorrectly evaluated
the __invokable trait via the converting constructor `function(Tp)` [with Tp = std::function]
whenever the copy constructor or copy assignment operator
was required. This patch further constrains that constructor to short
circut before evaluating the troublesome SFINAE when `Tp` matches
std::function.

The original patch is from Alex Lorenz.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312892 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-10 23:41:20 +00:00
Eric Fiselier
d5a494e058 Revert "Fix PR34298 - Allow std::function with an incomplete return type."
This reverts commit r312890 because the test case fails to compile for
older versions of Clang that reject initializing a const object without
a user defined constructor.

Since this patch should go into 5.0.1, I want to keep it an atomic change,
and will re-commit it with a fixed test case.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312891 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-10 23:37:47 +00:00
Eric Fiselier
f83132a4d1 Fix PR34298 - Allow std::function with an incomplete return type.
This patch fixes llvm.org/PR34298. Previously libc++ incorrectly evaluated
the __invokable trait via the converting constructor `function(Tp)` [with Tp = std::function]
whenever the copy constructor or copy assignment operator
was required. This patch further constrains that constructor to short
circut before evaluating the troublesome SFINAE when `Tp` matches
std::function.

The original patch is from Alex Lorenz.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312890 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-10 23:12:33 +00:00
Stephan T. Lavavej
e8c8bc9433 [libcxx] [test] Update for C++17 feature removals.
test/std/containers/Emplaceable.h
test/std/containers/NotConstructible.h
test/support/counting_predicates.hpp
Replace unary_function/binary_function inheritance with typedefs.

test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
test/std/utilities/function.objects/func.require/binary_function.pass.cpp
test/std/utilities/function.objects/func.require/unary_function.pass.cpp
Mark these tests as requiring 98/03/11/14 because 17 removed unary_function/binary_function.

test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp
Mark these tests as requiring 11/14 because 17 removed packaged_task allocator support.

test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
This test doesn't need to be skipped in C++17 mode. Only the construction of
std::function from an allocator needs to be skipped in C++17 mode.

test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
When testing these reference_wrapper features, unary_function inheritance is totally irrelevant.

test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
Define and use my_unary_function/my_binary_function to test the weak result type machinery
(which is still present in C++17, although deprecated).

test/support/msvc_stdlib_force_include.hpp
Now we can test C++17 strictly, without enabling removed features.

Fixes D36503.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@311705 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-24 21:24:08 +00:00
Stephan T. Lavavej
b859a78a6f [libcxx] [test] Rename _Up to U, etc. NFCI.
This improves readability and (theoretically) improves portability,
as _Ugly names are reserved.

This performs additional de-uglification, so all of these tests
follow the example of iterator.traits/empty.pass.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@310761 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-11 20:54:09 +00:00
Stephan T. Lavavej
302557b724 [libcxx] [test] Rename _Tp to T. NFCI.
This improves readability and (theoretically) improves portability,
as _Ugly names are reserved.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@310758 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-11 20:53:53 +00:00
Stephan T. Lavavej
6f13bfd436 [libcxx] [test] Fix URLs in comments and make them HTTPS. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@310156 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-05 00:44:24 +00:00
Stephan T. Lavavej
5d91f314f1 [libcxx] [test] Change comments to say C++ instead of c++. NFC.
This makes them consistent (many comments already used uppercase).

The special REQUIRES, UNSUPPORTED, and XFAIL comments are excluded from this change.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309468 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:35 +00:00
Stephan T. Lavavej
a8d0e52d11 [libcxx] [test] In func.wrap.func.con/alloc_F.pass.cpp, fix REQUIRES whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309466 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:25 +00:00
Stephan T. Lavavej
25072f0004 [libcxx] [test] Make files consistently end with newlines, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309465 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:22 +00:00
Stephan T. Lavavej
a686caad20 [libcxx] [test] Untabify, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309464 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:10 +00:00
Duncan P. N. Exon Smith
2b001ff730 func.wrap.func.con: Fix test comment
This tests moving `function`, not `const function`.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305648 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-18 15:34:47 +00:00
Eric Fiselier
e250cc68ce Cleanup test issues reported by STL @ Microsoft.
This patch cleans up a number of issues reported by STL, including:

1) Fix duplicate is_convertible test.
2) Move non-standard reference_wrapper tests under test/libcxx
3) Fix assumption that sizeof(wchar_t) == 32 in the codecvt and
   wstring_convert tests.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302870 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12 03:38:28 +00:00
Marshall Clow
4cbf03ea88 Mark LWG#2850 as complete. No functionality change; we had tests that covered it already. Just added comments to the tests. Thanks to K-ballo for the heads up.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302799 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11 13:55:20 +00:00
Eric Fiselier
ab2f54f103 Remove usages of _LIBCPP_MSVC which is never defined
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302736 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 21:40:58 +00:00
Eric Fiselier
76515a2dcf Implement LWG 2591 - Patch from K-Ballo
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302724 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-10 20:37:43 +00:00
Marshall Clow
570f32c8dd Can't test for noexcept on C++03; std::hash<nullptr_t> isn't available until C++17
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298580 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 06:20:18 +00:00
Marshall Clow
af552ba05a Implement P0599: 'noexcept for hash functions'. Fix a couple of hash functions (optional<T> and unique_ptr<T>) which were mistakenly marked as 'noexcept'. Reviewed as https://reviews.llvm.org/D31234
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298573 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 02:40:28 +00:00
Eric Fiselier
b7fd0be370 Update all bug URL's to point to https://bugs.llvm.org/...
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@295434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 08:37:03 +00:00
Saleem Abdulrasool
0849d28af1 test: squelch -Wreturn-type error
Add an unreachable marker to avoid a -Wreturn-type error when building
on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-12 17:37:44 +00:00
Eric Fiselier
66ed0bc836 Remove all usages of REQUIRES-ANY in the test suite.
Pending LIT changes are about to remove the REQUIRES-ANY keyword
in place of supporting boolean && and || within "REQUIRES". This
patch prepares libc++ for that change so that when applied
the bots don't lose their mind.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 09:11:08 +00:00
Eric Fiselier
952eaecfc6 Implement P0513R0 - "Poisoning the Hash"
Summary:
Exactly what the title says.

This patch also adds a `std::hash<nullptr_t>` specialization in C++17, but it was not added by this paper and I can't find the actual paper that adds it.

See http://wg21.link/P0513R0 for more info.

If there are no comments in the next couple of days I'll commit this

Reviewers: mclow.lists, K-ballo, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28938

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292684 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-21 00:02:12 +00:00
Stephan T. Lavavej
16e2ba19df [libcxx] [test] Fix comment typos, strip trailing whitespace.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 20:10:25 +00:00
Stephan T. Lavavej
c3564b92bc [libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants.
MSVC has compiler warnings C4127 "conditional expression is constant" (enabled
by /W4) and C6326 "Potential comparison of a constant with another constant"
(enabled by /analyze). They're potentially useful, although they're slightly
annoying to library devs who know what they're doing. In the latest version of
the compiler, C4127 is suppressed when the compiler sees simple tests like
"if (name_of_thing)", so extracting comparison expressions into named
constants is a workaround. At the same time, using std::integral_constant
avoids C6326, which doesn't look at template arguments.

test/std/containers/sequences/vector.bool/emplace.pass.cpp
Replace 1 == 1 with true, which is the same as far as the library is concerned.

Fixes D28837.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292432 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 20:09:56 +00:00
Eric Fiselier
152e5e61a1 Fix PR31489 - std::function self-swap segfaults
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290721 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-29 20:03:55 +00:00
Eric Fiselier
0a1cbcf2b7 fix newly failing c++03 tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290472 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-24 00:40:45 +00:00
Eric Fiselier
0e5ebbc77c Fix unused parameters and variables
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290459 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-23 23:37:52 +00:00
Eric Fiselier
a2cd270943 Enable the -Wsign-compare warning to better support MSVC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289363 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-11 05:31:00 +00:00
Stephan T. Lavavej
3e541a6172 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289111 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 21:38:57 +00:00
Stephan T. Lavavej
637a6f6005 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289106 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 21:38:01 +00:00
Stephan T. Lavavej
3ee8025384 [libcxx] [test] D26815: Fix an assumption about the state of moved-from 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287382 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-18 21:54:38 +00:00
Stephan T. Lavavej
e619862dbf [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER.
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@286007 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-04 20:26:59 +00:00
Eric Fiselier
fcdb3f77e8 Update LWG 2767 and add test case
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284324 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-16 03:45:06 +00:00
Eric Fiselier
48aa2e14a2 Add void_t and invoke feature test macros
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284209 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-14 07:19:52 +00:00
Marshall Clow
e29fb4c411 Implement http://wg21.link/p0302r1: Removing Allocator Support in std::function. These functions never worked, and as far as I know, no one ever called them.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284164 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-13 21:06:03 +00:00