Commit Graph

45 Commits

Author SHA1 Message Date
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
b7fe139a72 Fix typo
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289781 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15 07:23:44 +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
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
f008c5389e [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.
Add static_cast<short> when constructing pair<Whatever, short> from (Something, int).

Fixes D27540.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@289107 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 21:38:14 +00:00
Eric Fiselier
77dabb302b Test changes for P0504R0 "Revisiting in-place tag types for any/optional/variant". Patch from Casey Carter
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287249 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-17 19:23:35 +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
Dimitry Andric
ecb5332d41 Disable trivial pair copy/move tests when unsupported
Summary:
On FreeBSD, for ABI compatibility reasons, the pair trivial copy
constructor is disabled, using the aptly-named
`_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR` define.

Disable the related tests when this define is on, so they don't fail
unexpectedly.

Reviewers: emaste, rsmith, theraven, EricWF

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@284047 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 20:26:47 +00:00
Eric Fiselier
ee0db89aee Fix shadow warnings. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283618 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-07 22:10:35 +00:00
Eric Fiselier
89e826a160 Remove all instances of _LIBCPP_HAS_NO_RVALUE_REFERENCES from test/std/utilities
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@283032 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-01 10:46:01 +00:00
Eric Fiselier
66bdfe223e [libc++] Extension: Make move and forward constexpr in C++11.
Summary:
`std::move` and `std::forward` were not marked constexpr in C++11.  This can be very damaging because it makes otherwise constant expressions non-constant. For example:

```
#include <utility>
template <class T>
struct Foo {
  constexpr Foo(T&& tx) :  t(std::move(tx)) {}
  T t;
};
[[clang::require_constant_initialization]] Foo<int> f(42); // Foo should be constant initialized but C++11 move is not constexpr. As a result `f` is an unsafe global.
```

This patch applies `constexpr` to `move` and `forward` as an extension in C++11. Normally the library is not allowed to add `constexpr` because it may be observable to the user. In particular adding constexpr may cause valid code to stop compiling. However these problems only happen in more complex situations, like making `__invoke(...)` constexpr. `forward` and `move` are simply enough that applying `constexpr` is safe. 

Note that libstdc++ has offered this extension since at least 4.8.1.

Most of the changes in this patch are simply test cleanups or additions. The main changes in the tests are:

* Fold all `forward_N.fail.cpp` tests into a single `forward.fail.cpp` test using -verify.
* Delete most `move_only_N.fail.cpp` tests because they weren't actually testing anything.
* Fold `move_copy.pass.cpp` and `move_only.pass.cpp` into a single `move.pass.cpp` test.
* Add return type and noexcept tests for `forward` and `move`.




Reviewers: rsmith, mclow.lists, EricWF

Subscribers: K-ballo, loladiro

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282439 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-26 20:55:02 +00:00
Eric Fiselier
235d71f053 Fix pair::operator=(TupleLike&&).
This assignment operator was previously broken since the SFINAE always resulted
in substitution failure. This caused assignments to turn into
copy construction + assignment.

This patch was originally committed as r279953 but was reverted due to warnings
in the test-suite. This new patch corrects those warnings.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279955 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 01:43:41 +00:00
Eric Fiselier
0ecda7171c Revert r279953 - Fix pair::operator=(TupleLike&&)
The test emits warnings causing the test-suite to fail. Since I want this
patch merged into 3.9 I'll recommit it with a clean test.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279954 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 01:39:54 +00:00
Eric Fiselier
15ac5e4dc2 Fix pair::operator=(TupleLike&&).
This assignment operator was previously broken since the SFINAE always resulted
in substitution failure. This caused assignments to turn into
copy construction + assignment.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279953 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 01:09:47 +00:00
Eric Fiselier
1ed1df3a31 Unbreak C++03 build.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278323 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 08:15:35 +00:00
Eric Fiselier
92741e2493 Refactor test archetypes implementation.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@278319 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 07:04:14 +00:00
Eric Fiselier
b0cf9cb1bc Remove use of C++1z static assert in C++11 test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276608 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 04:56:32 +00:00
Eric Fiselier
e1445fd8ed Implement the std::pair parts of "Improving pair and tuple". Completes N4387.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276605 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 04:32:07 +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
932604f8d1 Don't SFINAE pair's copy assignment operator in C++03 mode.
In C++03 mode evaluating the SFINAE can cause a hard error due to
access control violations. This is a problem because the SFINAE
is evaluated as soon as the class is instantiated, and not later.




git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276594 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-25 00:48:36 +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
eef85d9044 Implement the in_place tags from p0032r3.
That paper also has changes to any/optional but those will
be implemented later.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276537 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-23 22:19:19 +00:00
Eric Fiselier
22bff1afcc Move remaining _LIBCPP_VERSION tests into test/libcxx
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273367 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 02:23:22 +00:00
Eric Fiselier
d24c465bea Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER.
This is a huge cleanup that helps make the libc++ test suite more portable.
Patch from STL@microsoft.com. Thanks STL!


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272716 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 21:31:42 +00:00
Eric Fiselier
bf5a4189d3 Remove _LIBCPP_TRIVIAL_PAIR_COPY_CTOR option.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272613 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 01:36:15 +00:00
Asiri Rathnayake
1575e3e813 [libcxx] Fix c++98 test failures.
Adds XFAIL/UNSUPPORTED lit tags as appropriate. Gets a clean test run
for -std=c++98 on Fedora 20.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271741 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-03 21:40:03 +00:00
Eric Fiselier
84acb1ec3f Remove trailing whitespace in test suite. Approved by Marshall Clow.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271435 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-01 21:35:39 +00:00
Asiri Rathnayake
a3eac518e6 [libcxx] Improve tests to use the UNSUPPORTED lit directive
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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271108 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-28 08:57:35 +00:00
Eric Fiselier
8a7462d163 Removing some trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@268543 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-04 20:29:19 +00:00
Eric Fiselier
a9ea11398d Void cast runtime-unused variables. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@268284 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-02 19:15:48 +00:00
Eric Fiselier
8f1e73dfd2 Add is_swappable/is_nothrow_swappable traits
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267079 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-21 23:38:59 +00:00
Ben Craig
9c6f00d616 XFAILing new test on C++03
initializer_list doesn't exist in C++03.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266820 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 21:07:30 +00:00
Ben Craig
d59d416bc9 Include initializer_list from utility
The C++11 and C++14 standards both say in the header <utility> synopsis that
<utility> shall include <initializer_list>.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 20:13:55 +00:00
Eric Fiselier
c8b24c6d54 Mark some test XFAIL for GCC 4.9 due to missing is_trivial* traits
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258287 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-20 04:59:57 +00:00
Marshall Clow
e5e9bff62a Add a bunch of missing includes in the test suite to make it more portable. Fixes bugs #26120 and #26121. Thanks to Jonathan Wakely for the reports and the patches.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@257474 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-12 14:51:04 +00:00
Eric Fiselier
9bef1ff571 [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default constructors.
Summary: This patch implements the solution for LWG Issue #2367. See http://cplusplus.github.io/LWG/lwg-active.html#2367

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13750

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@256325 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-23 08:20:26 +00:00
Eric Fiselier
199bee0ea7 [libcxx] LWG2485: get() should be overloaded for const tuple&&. Patch from K-Ballo.
Review: http://reviews.llvm.org/D14839

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@255941 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18 00:36:55 +00:00
Marshall Clow
f60d092766 Implement P0007: Constant View: A proposal for a std::as_const helper function template.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@253274 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 00:08:08 +00:00
Marshall Clow
bf94e48216 The test I cnecked in to check the fix for PR#24890 failed (as expected) w/o the fix, but for the wrong reason. Now it fails for the right reason.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248307 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 18:09:13 +00:00
Marshall Clow
842e3f6f51 Check in the test for PR#24890 that I forgot in previous commit
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248305 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 17:57:41 +00:00
Eric Fiselier
b47a434d60 Fix a handful of tests that fail in C++03
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243392 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-28 07:31:50 +00:00
Eric Fiselier
ee6bfb2117 Cleanup move/forward tests and remove references to __rv.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238270 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 00:51:08 +00:00
Eric Fiselier
8e706d2c3e [libcxx] Move tuple_size and tuple_element overloads for pair and array out of !defined(_LIBCPP_HAS_NO_VARIADICS) block.
Summary:
There is no reason to guard `tuple_size`, `tuple_element` and `get<I>(...)` for pair and array inside of `<__tuple>` so that they are only available when we have variadic templates.
This requires there be redundant declarations and definitions. It also makes it easy to get things wrong.

For example the following code should compile (and does in c++11).
```
#define _LIBCPP_HAS_NO_VARIADICS
#include <array>

int main()
{
  static_assert((std::tuple_size<std::array<int, 10> volatile>::value == 10), "");
}
```

This patch lifts the non-variadic parts of `tuple_size`, `tuple_types`, and `get<I>(...)` to the top of `<__tuple>` where they don't require variadic templates. This patch also removes `<__tuple_03>` because there is no longer a need for it.


Reviewers: danalbert, K-ballo, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7774

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@232492 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 15:08:03 +00:00
Eric Fiselier
a90c6dd460 Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-20 01:40:03 +00:00