[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / containers / sequences / array / size_and_alignment.pass.cpp
blobf585da6ce7a1267d8d4035f862613a546c128c46
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <array>
11 // template <class T, size_t N >
12 // struct array
14 // Test the size and alignment matches that of an array of a given type.
16 #include <array>
17 #include <iterator>
18 #include <type_traits>
19 #include <cstddef>
21 #include "test_macros.h"
24 template <class T, size_t Size>
25 struct MyArray {
26 T elems[Size];
29 template <class T, size_t Size>
30 void test() {
31 typedef T CArrayT[Size == 0 ? 1 : Size];
32 typedef std::array<T, Size> ArrayT;
33 typedef MyArray<T, Size == 0 ? 1 : Size> MyArrayT;
34 static_assert(sizeof(ArrayT) == sizeof(CArrayT), "");
35 static_assert(sizeof(ArrayT) == sizeof(MyArrayT), "");
36 static_assert(TEST_ALIGNOF(ArrayT) == TEST_ALIGNOF(MyArrayT), "");
37 #if defined(_LIBCPP_VERSION)
38 ArrayT a;
39 ((void)a);
40 static_assert(sizeof(ArrayT) == sizeof(a.__elems_), "");
41 static_assert(TEST_ALIGNOF(ArrayT) == __alignof__(a.__elems_), "");
42 #endif
45 template <class T>
46 void test_type() {
47 test<T, 1>();
48 test<T, 42>();
49 test<T, 0>();
52 struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType1 {
56 struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 {
57 char data[1000];
60 //static_assert(sizeof(void*) == 4, "");
62 int main(int, char**) {
63 test_type<char>();
64 test_type<int>();
65 test_type<double>();
66 test_type<long double>();
67 test_type<std::max_align_t>();
68 test_type<TestType1>();
69 test_type<TestType2>();
71 return 0;