[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / containers / sequences / array / array.data / data_const.pass.cpp
blob32c05d7ef35922ea20bd6fa568b23a728bc90c80
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 // const T* data() const;
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) {}
27 int main(int, char**)
30 typedef double T;
31 typedef std::array<T, 3> C;
32 const C c = {1, 2, 3.5};
33 const T* p = c.data();
34 assert(p[0] == 1);
35 assert(p[1] == 2);
36 assert(p[2] == 3.5);
39 typedef double T;
40 typedef std::array<T, 0> C;
41 const C c = {};
42 const T* p = c.data();
43 (void)p; // to placate scan-build
46 typedef NoDefault T;
47 typedef std::array<T, 0> C;
48 const C c = {};
49 const T* p = c.data();
50 LIBCPP_ASSERT(p != nullptr);
53 typedef std::max_align_t T;
54 typedef std::array<T, 0> C;
55 const C c = {};
56 const T* p = c.data();
57 LIBCPP_ASSERT(p != nullptr);
58 std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
59 assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
61 #if TEST_STD_VER > 14
63 typedef std::array<int, 5> C;
64 constexpr C c1{0,1,2,3,4};
65 constexpr const C c2{0,1,2,3,4};
67 static_assert ( c1.data() == &c1[0], "");
68 static_assert ( *c1.data() == c1[0], "");
69 static_assert ( c2.data() == &c2[0], "");
70 static_assert ( *c2.data() == c2[0], "");
72 #endif
74 return 0;