Commit Graph

52 Commits

Author SHA1 Message Date
Eric Fiselier
01fac08922 Tolerate Clangs new static_assert messages
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@349189 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-14 20:42:36 +00:00
Louis Dionne
5b19b0bb3f [libcxx] Add checks for unique value of array<T, 0>.begin() and array<T, 0>.end()
The standard section [array.zero] requires the return value of begin()
and end() methods of a zero-sized array to be unique. Eric Fiselier
clarifies: "That unique value cannot be null, and must be properly aligned".
This patch adds checks for the first part of this clarification: unique
value returned by these methods cannot be null.

Reviewed as https://reviews.llvm.org/D55366.
Thanks to Andrey Maksimov for the patch.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348509 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-06 18:24:39 +00:00
Louis Dionne
edfdc498b8 [libcxx] Make return value of array<T, 0>.data() checked only for libc++
The section array.zero says: "The return value of data() is unspecified".
This patch marks all checks of the array<T, 0>.data() return value as
libc++ specific.

Reviewed as https://reviews.llvm.org/D55364.
Thanks to Andrey Maksimov for the patch.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@348485 91177308-0d34-0410-b5e6-96231b3b80d8
2018-12-06 13:52:20 +00:00
Eric Fiselier
e3e576ae50 Revert "Move internal usages of alignof/__alignof to use _LIBCPP_ALIGNOF. "
This reverts commit 087f065cb0.

The tests were failing on 32 bit builds, and I don't have time
to clean them up right now. I'll recommit tomorrow with fixed tests.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347816 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-28 22:24:19 +00:00
Eric Fiselier
087f065cb0 Move internal usages of alignof/__alignof to use _LIBCPP_ALIGNOF.
Summary:
Starting in Clang 8.0 and GCC 8.0, `alignof` and `__alignof` return different values in same cases. Specifically `alignof` and `_Alignof` return the minimum alignment for a type, where as `__alignof` returns the preferred alignment. libc++ currently uses `__alignof` but means to use `alignof`. See  llvm.org/PR39713

This patch introduces the macro `_LIBCPP_ALIGNOF` so we can control which spelling gets used.

This patch does not introduce any ABI guard to provide the old behavior with newer compilers. However, if we decide that is needed, this patch makes it trivial to implement.

I think we should commit this change immediately, and decide what we want to do about the ABI afterwards. 

Reviewers: ldionne, EricWF

Reviewed By: EricWF

Subscribers: christof, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347787 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-28 18:16:02 +00:00
Louis Dionne
a320121c4c [libcxx] Add missing <cstddef> includes in tests
Some tests use type std::max_align_t, but don't include <cstddef> header
directly. As a result, these tests won't compile against some conformant
libraries.

Reviewed as https://reviews.llvm.org/D54645.
Thanks to Andrey Maksimov for the patch.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347232 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-19 17:39:50 +00:00
Marshall Clow
8f07eceb27 Update the array tests to not use a local type; removes warnings in C++03. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344417 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-12 21:24:44 +00:00
Marshall Clow
3a225ef042 Update the changes to the array tests (that I committed yesterday) to use the test_comparison routines that I committed last week. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338797 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-03 00:47:12 +00:00
Marshall Clow
88f5d7a38b Implement P1023: constexpr comparison operators for std::array
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@338668 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-02 02:11:06 +00:00
JF Bastien
e4063adf19 Mark deduction guide tests as failing on apple-clang-9
As discussed here: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058116.html
The tests fail on clang-5, as well as apple-clang-9. Mark them as such.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333479 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-29 23:28:04 +00:00
Marshall Clow
d1e11a1a6f Fix up the final bits of breakage due to clang v5 generating bad implicit template deduction guides - specifically for copy-ctors
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333381 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-28 19:20:21 +00:00
JF Bastien
3dfc68d12a Fix array deduction guide test breakage
No matching constructor

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333315 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-25 21:17:43 +00:00
Marshall Clow
f2c627db20 Disable 'missing-braces' warning
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@332779 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-18 22:21:33 +00:00
Marshall Clow
8a50bbc2b9 Implement deduction guides for <array>; Reviewed as https://reviews.llvm.org/D46964
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@332768 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-18 21:01:04 +00:00
Eric Fiselier
c0acd34e9a Fix size and alignment of array<T, 0>.
An array T[1] isn't necessarily the same say when it's
a member of a struct. This patch addresses that problem and corrects
the tests to deal with it.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324545 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 23:50:25 +00:00
Eric Fiselier
2e1fa09f68 Fix -verify static assert messages for older Clang versions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324529 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 21:25:25 +00:00
Eric Fiselier
6cb35ede81 [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.
Summary:
This patch fixes llvm.org/PR35491 and LWG2157  (https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324526 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 21:06:13 +00:00
Nirav Dave
610fc67809 Revert "[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types."
Revert "Fix initialization of array<const T, 0> with GCC."
Revert "Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed."

This reverts commit r324182, r324185, and r324194 which were causing issues with zero-length std::arrays.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324309 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-06 03:03:37 +00:00
Eric Fiselier
7d251c57ac correct comment about C++03 assignment operators
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324186 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 02:22:33 +00:00
Eric Fiselier
122c064a76 Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed.
The standard isn't exactly clear how std::array should handle zero-sized arrays
with const element types. In particular W.R.T. copy assignment, swap, and fill.

This patch takes the position that those operations should be ill-formed,
and makes changes to libc++ to make it so.

This follows up on commit r324182.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324185 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 02:17:02 +00:00
Eric Fiselier
f3224ac007 [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.
Summary:
This patch fixes llvm.org/PR35491 and LWG2157  (https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324182 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-04 01:03:08 +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
Marshall Clow
88626bf496 First part of P0600 - '[[nodiscard] in the standard library'. Mark the 'empty()' methods of all the containers as nodiscard. If you're calling empty() w/o looking at the result, you probably meanto to call 'clear()'. c++2a only
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318269 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 05:51:26 +00:00
Marshall Clow
4f009913df More missing tests - array<>::size() and array<>::max_size()
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318256 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 02:31:14 +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
Marshall Clow
568c481c7b [array.tuple]/1 says that instantiating tuple_element<N, array<T, M>> is ill-formed if N >= M. We didn't do that. Add a static_assert to cause a failure, and a test that checks that we failed
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@305191 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-12 14:41:37 +00:00
Eric Fiselier
6c26be6c87 Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <array>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300412 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 02:50:40 +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
Marshall Clow
d25c997c77 Implement the missing constexpr stuff in <array>. Fixes PR#31645.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292091 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-16 03:02:10 +00:00
Stephan T. Lavavej
51eb1be9ec [libcxx] [test] Strip trailing whitespace. NFC, no code review.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291322 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-07 01:12:15 +00:00
Marshall Clow
e22af6b758 Implement the last bit of P0031: 'A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access' for C++17
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290976 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-04 17:58:17 +00:00
Roger Ferrer Ibanez
72ac68a980 Protect std::array tests under noexceptions
Skip tests that expect exceptions be thrown. Also add missing asserts.

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



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288165 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-29 17:10:29 +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
8dc5b6eba9 Update -verify test to use new static assert message
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@282352 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-25 08:30:05 +00:00
Eric Fiselier
0fc5603d78 Make std::array typedef tests more portable.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@274210 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 04:54:00 +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
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
Eric Fiselier
6f367f088c Fix C++03 build breakage
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@267090 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-22 00:47:15 +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
Marshall Clow
d7d1bda0f4 Add some more tests for the containers type requirements
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263029 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-09 17:19:07 +00:00
Marshall Clow
8d48d9b2cc non-member swap for array was mistakenly taking const ref params. Fixed and added test. Thanks to Ben Craig for the catch
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@262866 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-07 21:57:10 +00:00
Marshall Clow
20fefa6b3a Add additional tests to ensure that we DTRT with short lists. This is LWG#2590, but there are no code changes, just additional tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@261648 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-23 16:25:20 +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
Asiri Rathnayake
cc2e93cff0 Make it possible to build a no-exceptions variant of libcxx.
Fixes a small omission in libcxx that prevents libcxx being built when
-DLIBCXX_ENABLE_EXCEPTIONS=0 is specified.

This patch adds XFAILS to all those tests that are currently failing
on the new -fno-exceptions library variant. Follow-up patches will
update the tests (progressively) to cope with the new library variant.

Change-Id: I4b801bd8d8e4fe7193df9e55f39f1f393a8ba81a

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@252598 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-10 11:41:22 +00:00
Eric Fiselier
237206bfda Suppress array initialization warnings in std::experimental::apply tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248987 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 07:05:38 +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
b0be44f963 Commit file missing from r242629
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242630 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-19 00:11:50 +00:00
Eric Fiselier
02bb4bdb49 Fix warnings in array and assoc containers
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242629 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-18 23:56:04 +00:00
Marshall Clow
b5b66923e3 Add tests to ensure that string/vector/array have contiguous iterators - which they did. Mark N4284 as complete
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238233 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 18:57:27 +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