summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/array
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-02-07 23:50:25 +0000
committerEric Fiselier <eric@efcs.ca>2018-02-07 23:50:25 +0000
commit1a78ae3c895d0520bbb8ad2f154e737d52fe7ae2 (patch)
treee34d2a482daab62cc393157715037037426b6c28 /libcxx/test/std/containers/sequences/array
parent06ac8cfbd103b2a024d6c1c01ae8912ebce523a0 (diff)
downloadbcm5719-llvm-1a78ae3c895d0520bbb8ad2f154e737d52fe7ae2.tar.gz
bcm5719-llvm-1a78ae3c895d0520bbb8ad2f154e737d52fe7ae2.zip
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. llvm-svn: 324545
Diffstat (limited to 'libcxx/test/std/containers/sequences/array')
-rw-r--r--libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp b/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp
index d01e1ceb792..966d063fe17 100644
--- a/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp
+++ b/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp
@@ -21,12 +21,26 @@
#include "test_macros.h"
+
+template <class T, size_t Size>
+struct MyArray {
+ T elems[Size];
+};
+
template <class T, size_t Size>
void test() {
typedef T CArrayT[Size == 0 ? 1 : Size];
typedef std::array<T, Size> ArrayT;
- static_assert(sizeof(CArrayT) == sizeof(ArrayT), "");
- static_assert(TEST_ALIGNOF(CArrayT) == TEST_ALIGNOF(ArrayT), "");
+ typedef MyArray<T, Size == 0 ? 1 : Size> MyArrayT;
+ static_assert(sizeof(ArrayT) == sizeof(CArrayT), "");
+ static_assert(sizeof(ArrayT) == sizeof(MyArrayT), "");
+ static_assert(TEST_ALIGNOF(ArrayT) == TEST_ALIGNOF(MyArrayT), "");
+#if defined(_LIBCPP_VERSION)
+ ArrayT a;
+ ((void)a);
+ static_assert(sizeof(ArrayT) == sizeof(a.__elems_), "");
+ static_assert(TEST_ALIGNOF(ArrayT) == __alignof__(a.__elems_), "");
+#endif
}
template <class T>
@@ -44,6 +58,8 @@ struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 {
char data[1000];
};
+//static_assert(sizeof(void*) == 4, "");
+
int main() {
test_type<char>();
test_type<int>();
OpenPOWER on IntegriCloud