Commit Graph

75 Commits

Author SHA1 Message Date
Stephan T. Lavavej
dd2a900c0b [libcxx] [test] Fix MSVC warnings, null pointer deref.
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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@320535 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 00:51:27 +00:00
Billy Robert O'Neal III
f27631034a Add another test_macros.h include I missed to tuple.by.type.pass.cpp
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318830 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-22 12:29:17 +00:00
Billy Robert O'Neal III
7e250fcdc1 Change (void) casts to TEST_IGNORE_NODISCARD, as requested by Eric. Reviewed as https://reviews.llvm.org/D40065
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318804 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 21:37:26 +00:00
Benjamin Kramer
5384fd8538 Placate unused variable warnings uncovered by improvements to clang's -Wunused-variable
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@315809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-14 15:52:38 +00:00
Eric Fiselier
8a29c9d39b Add C++17 explicit deduction guides to std::pair.
This patch adds the newly standardized deduction guides
for std::pair, allowing it to work class template deduction.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@314864 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-04 00:04:26 +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
3497449a37 [libcxx] [test] Fix -Wmismatched-tags in tuple_size_structured_bindings.pass.cpp.
Clang and C1XX both complain about mismatched class/struct, but libc++ and MSVC's STL
differ on what they use for tuple_element/tuple_size, so there's no way to win here.

I'm reverting this part of my previous change. In the future, I'll have to suppress
the warning for one compiler or the other.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305854 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-20 21:10:53 +00:00
Stephan T. Lavavej
b836deb5db [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305848 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-20 21:00:02 +00:00
Stephan T. Lavavej
750da9c572 [libcxx] [test] Add more tests to tuple_size_structured_bindings.pass.cpp and make it friendlier to C1XX.
Style/paranoia: 42.1 doesn't have an exact binary representation. Although this doesn't
cause failures, it makes me uncomfortable, so I'm changing it to 42.5.

C1XX rightly warns about unreferenced variables. Adding tests for their values
makes C1XX happy and improves test coverage.

C1XX (somewhat obnoxiously) warns about seeing a struct specialized as a class.
Although the Standard doesn't care, saying struct consistently is better.
(The Standard itself is still inconsistent about whether to depict tuple_element
and tuple_size as structs or classes.)

Fixes D33953.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305843 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-20 20:34:50 +00:00
Eric Fiselier
c597e3867e XFAIL tuple deduction guide test on GCC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@304969 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-08 08:03:35 +00:00
Eric Fiselier
3113ac6f85 Add tests for class template deduction on std::tuple.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@304967 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-08 07:18:17 +00:00
Eric Fiselier
2d31e197db Fix or move tests with non-standard assumptions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302862 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12 01:44:51 +00:00
Marshall Clow
8fdd8117a9 Mark LWG#2796 as complete. No functionality change; we had tests that covered it already. Just added comments to the tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302798 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11 13:51:09 +00:00
Eric Fiselier
d311b3c55a Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the utilities library
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300635 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 00:56:32 +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
Eric Fiselier
07d23d5d93 Implement LWG 2773 - std::ignore should be constexpr.
In addition to the PR for LWG 2773 this patch also ensures
that each of std::ignores constructors or assignment operators
are constexpr.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294165 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-06 01:25:31 +00:00
Stephan T. Lavavej
19ab479cc2 [libcxx] [test] Fix comment typos.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294160 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:48:20 +00:00
Marshall Clow
ec1d3f7e2d Revert previous cleanup; I got too agressive removing #ifdefs
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-23 18:00:15 +00:00
Marshall Clow
45f4ec28a2 Removed some un-needed ifdefs
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292806 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-23 17:25:38 +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
Eric Fiselier
d0f20b2b08 Fix XPASS buildbot failure related to structured bindings
The test was previously set to XFAIL if __cpp_structured_bindings
wasn't defined. However there are Clang 4.0 versions which do not
define this macro but do provide structured bindings, which causes
the test to pass unexpectedly.

This patch changes the XFAIL to an UNSUPPORTED.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291060 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-05 01:34:14 +00:00
Eric Fiselier
2b3c8a28b4 Fix verify test on 32 bit systems
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291031 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04 23:30:06 +00:00
Eric Fiselier
06a0febbbd [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings
Summary:
This patch attempts to re-implement a fix for LWG 2770, but not the actual specified PR. 

The PR for 2770 specifies tuple_size<T const> as only conditionally providing a `::value` member. However C++17 structured bindings require `tuple_size<T const>` to be complete only if  `tuple_size<T>` is also complete. Therefore this patch implements only provides the specialization `tuple_size<T CV>` iff `tuple_size<T>` is a complete type.

This fixes http://llvm.org/PR31513.

Reviewers: mclow.lists, rsmith, mpark

Subscribers: mpark, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291019 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04 22:38:46 +00:00
Eric Fiselier
408438494b Re-implement LWG 2770 - Fix tuple_size with structured bindings.
This patch implements the correct PR for LWG 2770. It also makes the primary
tuple_size template incomplete again which fixes part of llvm.org/PR31513.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290846 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-02 23:54:13 +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
1d0d379c40 Fix XFAILS for is_trivially_destructible trait
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289802 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15 11:00:07 +00:00
Eric Fiselier
cdc59e576e Add tests for LWG 2796
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289780 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15 07:15:39 +00:00
Eric Fiselier
90314c55d1 Add more test cases for PR31384
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289778 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15 07:05:19 +00:00
Eric Fiselier
1739d3ef0a Add test case for PR31384
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289774 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15 06:38:07 +00:00
Eric Fiselier
9663ee4d4f Revert r289727 due to PR31384
This patch reverts the changes to tuple which fixed construction from
types derived from tuple. It breaks the code mentioned in llvm.org/PR31384.
I'll follow this commit up with a test case.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289773 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15 06:34:54 +00:00
Eric Fiselier
c480bc55cd Work around bug in initialization of std::array base class with older clangs
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14 23:24:12 +00:00
Eric Fiselier
18e56b438e [libcxx] Fix tuple construction/assignment from types derived from tuple/pair/array.
Summary:
The standard requires tuple have the following constructors:
```
tuple(tuple<OtherTypes...> const&);
tuple(tuple<OtherTypes...> &&);
tuple(pair<T1, T2> const&);
tuple(pair<T1, T2> &&);
tuple(array<T, N> const&);
tuple(array<T, N> &&);
```
However libc++ implements these as a single constructor with the signature:
```
template <class TupleLike, enable_if_t<__is_tuple_like<TupleLike>::value>>
tuple(TupleLike&&);
```

This causes the constructor to reject types derived from tuple-like types; Unlike if we had all of the concrete overloads, because they cause the derived->base conversion in the signature.

This patch fixes this issue by detecting derived types and the tuple-like base they are derived from. It does this by creating an overloaded function with signatures for each of tuple/pair/array and checking if the possibly derived type can convert to any of them.

This patch fixes [PR17550]( https://llvm.org/bugs/show_bug.cgi?id=17550)

This patch 

Reviewers: mclow.lists, K-ballo, mpark, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289727 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14 22:22:38 +00:00
Stephan T. Lavavej
aa1d62b4af [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove an unused variable.
test/support/test_macros.h
For convenience/greppability, add macros for libcxx-specific static_asserts about noexceptness.

(Moving the definitions of ASSERT_NOEXCEPT/ASSERT_NOT_NOEXCEPT isn't technically necessary
because they're macros, but I think it's better style to define stuff before using it.)

test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
There was a completely unused `TrackedCallable obj;`.

apply() isn't depicted with conditional noexcept in C++17.

test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
Now that we have LIBCPP_ASSERT_NOEXCEPT, use it.

Fixes D27622.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289264 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-09 19:53:08 +00:00
Eric Fiselier
f2f3637d40 Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.
This patch removes libc++'s tuple extension which allowed it to be
constructed from fewer initializers than elements; with the remaining
elements being default constructed. However the implicit version of
this extension breaks conforming code. For example:

    int fun(std::string);
    int fun(std::tuple<std::string, int>);
    int x = fun("hello"); // ambigious

Because existing code may already depend on this extension it can be re-enabled
by defining _LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION.

Note that the explicit version of this extension is still supported,
although it's somewhat less useful than the implicit one.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289158 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 23:57:08 +00:00
Stephan T. Lavavej
0e8cbce107 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.
Instead of storing double in double and then truncating to int, store int in long
and then widen to long long. This preserves test coverage (as these tests are
interested in various tuple conversions) while avoiding truncation warnings.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
Since we aren't physically truncating anymore, t1 is equal to p0.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
One edit is different from the usual pattern. Previously, we were storing
double in double and then converting to A, which has an implicitly converting
constructor from int. Now, we're storing int in int and then converting to A,
avoiding the truncation.

Fixes D27542.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289109 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 21:38:32 +00:00
Stephan T. Lavavej
62cd72c4e6 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 4/7.
Change char to long and remove some char casts. This preserves test coverage for tuple's
heterogeneous comparisons, while avoiding int-to-char truncation warnings.

Fixes D27541.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289108 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 21:38:23 +00:00
Stephan T. Lavavej
e2dbcaf969 [libcxx] [test] D27266: Remove spurious semicolons.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288750 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 01:14:06 +00:00
Eric Fiselier
f9a20c2c38 Implement LWG 2770 - Make tuple_size<T> defined for all T
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@286779 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-13 20:43:50 +00:00
Eric Fiselier
fc044a1ff2 Fix PR30979 - tuple<move_only> is constructible from move_only const&
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@286774 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-13 19:54:31 +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
26cbb8d03e Make make_from_tuple tests more portable. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284943 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-23 18:55:51 +00:00
Eric Fiselier
daa895f887 Add missing <memory> include in test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283633 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 00:59:16 +00:00
Eric Fiselier
4be71c6619 Recommit r276548 - Make pair/tuples assignment operators SFINAE properly.
I think I've solved issues with is_assignable and references to incomplete
types. The updated patch adds tests for this case.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276603 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 02:36:42 +00:00
Eric Fiselier
c76d8f7ff4 Revert r276548 - Make pair/tuples assignment operators SFINAE properly.
This is a breaking change. The SFINAE required is instantiated the second
the class is instantiated, and this can cause hard SFINAE errors
when applied to references to incomplete types. Ex.

struct IncompleteType;
extern IncompleteType it;
std::tuple<IncompleteType&> t(it); // SFINAE will blow up.




git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276598 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 01:45:07 +00:00
Eric Fiselier
e3ecccdf48 Fix MSVC unreferenced parameter warning. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276583 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24 23:32:48 +00:00
Eric Fiselier
8b5233f11c Make pair/tuples assignment operators SFINAE properly.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276548 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-24 05:51:11 +00:00
Eric Fiselier
c79e8b692d Suppress warning in make_from_tuple tests.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275748 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 01:52:46 +00:00
Eric Fiselier
5839fedf28 Implement C++17 tuple bits. Including apply and make_from_tuple.
This patch upgrades <tuple> to be C++17 compliant by implementing:

* tuple_size_v: This was forgotten when implementing the other _v traits.
* std::apply: This was added via LFTS v1 in p0220r1.
* std::make_from_tuple: This was added in p0209r2.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@275745 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-18 00:35:56 +00:00
Eric Fiselier
990090f2ad Handle std::get<T>(...) for std::tuple<>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274422 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02 03:46:08 +00:00
Eric Fiselier
22c3e76205 Rewrite std::get<Type>(...) helper using constexpr functions.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274418 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02 03:18:30 +00:00