[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / containers / sequences / array / array.data / data.pass.cpp
blobce1843eb5496b0fb75975e384a04b6906595c1a3
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 // T *data();
13 #include <array>
14 #include <cassert>
15 #include <cstddef> // for std::max_align_t
17 #include "test_macros.h"
19 // std::array is explicitly allowed to be initialized with A a = { init-list };.
20 // Disable the missing braces warning for this reason.
21 #include "disable_missing_braces_warning.h"
23 struct NoDefault {
24 NoDefault(int) {}
28 int main(int, char**)
31 typedef double T;
32 typedef std::array<T, 3> C;
33 C c = {1, 2, 3.5};
34 T* p = c.data();
35 assert(p[0] == 1);
36 assert(p[1] == 2);
37 assert(p[2] == 3.5);
40 typedef double T;
41 typedef std::array<T, 0> C;
42 C c = {};
43 T* p = c.data();
44 LIBCPP_ASSERT(p != nullptr);
47 typedef double T;
48 typedef std::array<const T, 0> C;
49 C c = {{}};
50 const T* p = c.data();
51 static_assert((std::is_same<decltype(c.data()), const T*>::value), "");
52 LIBCPP_ASSERT(p != nullptr);
55 typedef std::max_align_t T;
56 typedef std::array<T, 0> C;
57 const C c = {};
58 const T* p = c.data();
59 LIBCPP_ASSERT(p != nullptr);
60 std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
61 assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
64 typedef NoDefault T;
65 typedef std::array<T, 0> C;
66 C c = {};
67 T* p = c.data();
68 LIBCPP_ASSERT(p != nullptr);
71 return 0;