summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r290750 - Fix PR19460 - std::ios is convertible to int.Eric Fiselier2016-12-301-9/+0
| | | | llvm-svn: 290752
* Add missing include in test.Eric Fiselier2016-12-301-0/+2
| | | | llvm-svn: 290751
* Fix PR19460 - std::ios is convertible to int.Eric Fiselier2016-12-301-0/+7
| | | | | | | | | | | | | | | std::basic_ios has an operator bool(). In C++11 and later it is explicit, and only allows contextual implicit conversions. However explicit isn't available in C++03 which causes std::istream (et al) to have an implicit conversion to int. This can easily cause ambiguities when calling operator<< and operator>>. This patch uses a "bool-like" type in C++03 to work around this. The "bool-like" type is an arbitrary pointer to member function type. It will not convert to either int or void*, but will convert to bool. llvm-svn: 290750
* Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions.Ed Schouten2016-12-302-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in r240527 I added a knob to prevent thread-unsafe functions from being exposed. mblen(), mbtowc() and wctomb() were also added to this list, as the latest issue of POSIX doesn't require these functions to be thread-safe. It turns out that the only circumstance in which these functions are not thread-safe is in case they are used in combination with state-dependent character sets (e.g., Shift-JIS). According to Austin Group Bug 708, these character sets "[...] are mostly a relic of the past and which were never supported on most POSIX systems". Though in many cases the use of these functions can be prevented by using the reentrant counterparts, they are the only functions that allow you to query whether the locale's character set is state-dependent. This means that omitting these functions removes actual functionality. Let's be a bit less pedantic and drop the guards around these functions. Links: http://austingroupbugs.net/view.php?id=708 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm Reviewed by: ericwf Differential Revision: https://reviews.llvm.org/D21436 llvm-svn: 290748
* Get ctype_byname tests passing on Linux.Eric Fiselier2016-12-306-75/+96
| | | | llvm-svn: 290746
* Fix PR31489 - std::function self-swap segfaultsEric Fiselier2016-12-292-94/+195
| | | | llvm-svn: 290721
* Fix debug mode for vector/list and cleanup testsEric Fiselier2016-12-2814-502/+16
| | | | llvm-svn: 290657
* Implement P0435R1 - Resolving LWG issues for common_typeEric Fiselier2016-12-271-10/+183
| | | | llvm-svn: 290627
* Fix PR31481 - 3+ parameter common_type isn't SFINAE friendlyEric Fiselier2016-12-271-5/+17
| | | | llvm-svn: 290624
* Fix bug #31387 - not checking end iterator when parsing decimal escape. ↵Marshall Clow2016-12-241-0/+44
| | | | | | Thanks to Karen for the report. llvm-svn: 290500
* Enable -Wunreachable-code and fix duplicate warning flagsEric Fiselier2016-12-241-1/+2
| | | | llvm-svn: 290486
* Fix -Wsign-compare warnings in re tests that only run on OS XEric Fiselier2016-12-247-224/+224
| | | | llvm-svn: 290481
* Fix sign-compare warnings on ARM platforms caused by wchar_t being unsignedEric Fiselier2016-12-241-7/+7
| | | | llvm-svn: 290480
* Fix warning caused by platforms providing a signed wint_tEric Fiselier2016-12-241-1/+2
| | | | llvm-svn: 290477
* Fix yet another missed -Wunused warning. Hopefully this is the last oneEric Fiselier2016-12-241-7/+8
| | | | llvm-svn: 290476
* Fix unused warning which only triggers in C++11Eric Fiselier2016-12-241-0/+3
| | | | llvm-svn: 290475
* fix warnings only produced by apple-clangEric Fiselier2016-12-248-44/+27
| | | | llvm-svn: 290474
* fix newly failing c++03 testsEric Fiselier2016-12-242-3/+8
| | | | llvm-svn: 290472
* Fix unused parameters and variablesEric Fiselier2016-12-2392-191/+176
| | | | llvm-svn: 290459
* Add apple-clang-8 to list of XFAILS for some variant tests. Patch from ↵Eric Fiselier2016-12-232-2/+2
| | | | | | Michael Park llvm-svn: 290440
* Fix XFAILS for is_trivially_destructible traitEric Fiselier2016-12-152-6/+0
| | | | llvm-svn: 289802
* Fix typoEric Fiselier2016-12-151-1/+1
| | | | llvm-svn: 289781
* Add tests for LWG 2796Eric Fiselier2016-12-152-0/+73
| | | | llvm-svn: 289780
* Add more test cases for PR31384Eric Fiselier2016-12-151-9/+59
| | | | llvm-svn: 289778
* Add test case for PR31384Eric Fiselier2016-12-151-0/+38
| | | | llvm-svn: 289774
* Revert r289727 due to PR31384Eric Fiselier2016-12-152-269/+0
| | | | | | | | 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. llvm-svn: 289773
* XFAIL test for more apple-clang versionsEric Fiselier2016-12-151-1/+1
| | | | llvm-svn: 289767
* Work around bug in initialization of std::array base class with older clangsEric Fiselier2016-12-142-3/+9
| | | | llvm-svn: 289741
* Fix PR31378 - std::list::remove should not require a default constructible ↵Eric Fiselier2016-12-141-33/+47
| | | | | | | | | | | | allocator. In list::remove we collect the nodes we're removing in a seperate list instance. However we construct this list using the default constructor which default constructs the allocator. However allocators are not required to be default constructible. This patch fixes the construction of the second list. llvm-svn: 289735
* [libcxx] [test] Fix MSVC x64 truncation warnings with 32-bit allocator ↵Stephan T. Lavavej2016-12-144-4/+4
| | | | | | | | | | | | | | | | size_type/difference_type. test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp Iterate with C::size_type because that's what operator[] takes. test/std/containers/sequences/vector/contiguous.pass.cpp test/std/strings/basic.string/string.require/contiguous.pass.cpp Add static_cast<typename C::difference_type> because that's what the iterator's operator+ takes. Fixes D27777. llvm-svn: 289734
* [libcxx] Fix tuple construction/assignment from types derived from ↵Eric Fiselier2016-12-142-0/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 289727
* XFAIL test on apple-clang-7.0Eric Fiselier2016-12-141-1/+1
| | | | llvm-svn: 289716
* [libcxx] Fix PR24075, PR23841 - Add ↵Eric Fiselier2016-12-146-0/+891
| | | | | | | | | | | | | | | | | | | | scoped_allocator_adaptor::construct(pair<T, U>*, ...) overloads. Summary: For more information see: * https://llvm.org/bugs/show_bug.cgi?id=23841 * https://llvm.org/bugs/show_bug.cgi?id=24075 I hope you have as much fun reviewing as I did writing these insane tests! Reviewers: mclow.lists, AlisdairM, EricWF Subscribers: AlisdairM, Potatoswatter, cfe-commits Differential Revision: https://reviews.llvm.org/D27612 llvm-svn: 289710
* Recommit r286884: P0503R0, adopted in Issaquah, rewords some requirements on ↵Eric Fiselier2016-12-143-3/+47
| | | | | | | | | | | | | | | nullptr_t and istream_iterator. No code changes were needed, but I updated a few tests. Also resolved P0509 and P0521, which required no changes to the library or tests. This patch was reverted due to llvm.org/PR31016. There is a bug in Clang 3.7 which causes default.pass.cpp to fails. That test is now marked as XFAIL for that clang version. This patch was originally authored by Marshall Clow. llvm-svn: 289708
* [libcxx] [test] Fix size_t-to-int truncation warnings in syserr.hash.Stephan T. Lavavej2016-12-132-4/+4
| | | | | | | | | | | | | | | | After r289363, these tests were triggering MSVC x64 warning C4267 "conversion from 'size_t' to 'int', possible loss of data" by taking 0, 2, and 10 as std::size_t, then constructing error_code(int, const error_category&) or error_condition(int, const error_category&) from that (N4618 19.5.3.2 [syserr.errcode.constructors]/3, 19.5.4.2 [syserr.errcondition.constructors]/3). The fix is simple: take these ints as int, pass them to the int-taking constructor, and perform a value-preserving static_cast<std::size_t> when comparing them to `std::size_t result`. Fixes D27691. llvm-svn: 289512
* [libcxx] [test] Change ifstream constructor tests to handle read-only files.Stephan T. Lavavej2016-12-124-24/+36
| | | | | | | | | | | | | Certain source control systems like to set the read-only bit on their files, which interferes with opening "test.dat" for both input and output. Fortunately, we can work around this without losing test coverage. Now, the ifstream.cons tests have comments referring to the ofstream.cons tests. There, we're creating writable files (not checked into source control), where the ifstream constructor tests will succeed. Fixes D26814. llvm-svn: 289463
* [libcxx] [test] Fix an improper assumption about Null Forward Iterators.Stephan T. Lavavej2016-12-121-4/+0
| | | | | | | | Value-initialized iterators still can't be compared to those with parents. Fixes D26626. llvm-svn: 289462
* Enable the -Wsign-compare warning to better support MSVCEric Fiselier2016-12-1164-277/+300
| | | | llvm-svn: 289363
* Fix copy/paste errors introduced in r289358Eric Fiselier2016-12-112-16/+16
| | | | llvm-svn: 289359
* Fix undefined behavior in container swap tests.Eric Fiselier2016-12-1117-183/+180
| | | | | | | | | | | | These swap tests were swapping non-POCS non-equal allocators which is undefined behavior. This patch changes the tests to use allocators which compare equal. In order to test that the allocators were not swapped I added an "id" field to test_allocator which does not participate in equality but does propagate across copies/swaps. This patch is based off of D26623 which was submitted by STL. llvm-svn: 289358
* Fix yet another dynamic exception specEric Fiselier2016-12-111-2/+2
| | | | llvm-svn: 289357
* Fix more uses of dynamic exception specifications in C++17Eric Fiselier2016-12-1118-44/+79
| | | | llvm-svn: 289356
* [libc++] Fix support for multibyte thousands_sep and decimal_point in ↵Eric Fiselier2016-12-114-28/+49
| | | | | | | | | | | | | | | | | | moneypunct_byname and numpunct_byname. Summary: The underlying C locales provide the `thousands_sep` and `decimal_point` as strings, possible with more than one character. We currently don't handle this case even for `wchar_t`. This patch properly converts the mbs -> wide character for `moneypunct_byname<wchar_t>`. For the `moneypunct_byname<char>` case we attempt to narrow the WC and if that fails we also attempt to translate it to some reasonable value. For example we translate U00A0 (non-breaking space) into U0020 (regular space). If none of these conversions succeed then we simply allow the base class to provide a fallback value. Reviewers: mclow.lists, EricWF Subscribers: vangyzen, george.burgess.iv, cfe-commits Differential Revision: https://reviews.llvm.org/D24218 llvm-svn: 289347
* [libcxx] [test] Fix string_view tests.Stephan T. Lavavej2016-12-092-5/+7
| | | | | | | | | | | | | | | | | | test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp Passing -1 to size_t triggers signed/unsigned mismatch warnings because it's a value-modifying conversion. Add static_cast<size_t> to soothe the compiler. (This file refers to size_t unqualified.) test/std/strings/string.view/string.view.ops/substr.pass.cpp Add <algorithm> for std::min() and <stdexcept> for std::out_of_range. N4618 21.4.2.4 [string.view.access]/1: "Requires: pos < size()." /4: "[ Note: Unlike basic_string::operator[], basic_string_view::operator[](size()) has undefined behavior instead of returning charT(). -end note ]" Fixes D27633. llvm-svn: 289283
* [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, ↵Stephan T. Lavavej2016-12-092-7/+6
| | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 289264
* Fix missing const on set::count. Patch from Andrey KhalyavinEric Fiselier2016-12-091-9/+11
| | | | llvm-svn: 289204
* Refactor uses_allocator test types for upcoming fixesEric Fiselier2016-12-095-0/+23
| | | | llvm-svn: 289197
* Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.Eric Fiselier2016-12-081-7/+14
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 289158
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-0814-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-086-9/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | loss of data", part 6/7. test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp (Affects 64-bit architectures.) Include <cstddef> so we can take/return std::ptrdiff_t (instead of int) in random_shuffle()'s RNG. (C++14 D.12 [depr.alg.random.shuffle]/2 says that difference_type is used, and we're shuffling a plain array.) test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp (Affects 64-bit architectures.) Include <iterator> because we're already using iterator_traits. Then, store the result of subtracting two RanIts as difference_type instead of long (which truncates on LLP64 architectures like MSVC x64). test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp (Affects 64-bit architectures.) Include <cstddef> so we can store the result of subtracting two pointers as std::ptrdiff_t (instead of int). test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp (Affects 32-bit architectures.) Sometimes, size_t is too small. That's the case here, where tellg() returns pos_type (N4606 27.7.2.3 [istream.unformatted]/39). Implementations can have 64-bit pos_type (to handle large files) even when they have 32-bit size_t. Fixes D27543. llvm-svn: 289110
OpenPOWER on IntegriCloud