[CodeGen] Remove some implict conversions of MCRegister to unsigned by using(). NFC
[llvm-project.git] / libcxx / test / std / containers / sequences / vector / vector.data / data_const.pass.cpp
blob0cf0b22047352e61f684ad1f6cbe514a217ce4fe
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 // <vector>
11 // const_pointer data() const;
13 #include <vector>
14 #include <cassert>
16 #include "test_macros.h"
17 #include "min_allocator.h"
18 #include "asan_testing.h"
20 struct Nasty {
21 TEST_CONSTEXPR Nasty() : i_(0) {}
22 TEST_CONSTEXPR Nasty(int i) : i_(i) {}
23 TEST_CONSTEXPR_CXX20 ~Nasty() {}
25 Nasty * operator&() const { assert(false); return nullptr; }
26 int i_;
29 TEST_CONSTEXPR_CXX20 bool tests()
32 const std::vector<int> v;
33 assert(v.data() == 0);
34 assert(is_contiguous_container_asan_correct(v));
37 const std::vector<int> v(100);
38 assert(v.data() == std::addressof(v.front()));
39 assert(is_contiguous_container_asan_correct(v));
42 const std::vector<Nasty> v(100);
43 assert(v.data() == std::addressof(v.front()));
44 assert(is_contiguous_container_asan_correct(v));
46 #if TEST_STD_VER >= 11
48 const std::vector<int, min_allocator<int>> v;
49 assert(v.data() == 0);
50 assert(is_contiguous_container_asan_correct(v));
53 const std::vector<int, min_allocator<int>> v(100);
54 assert(v.data() == &v.front());
55 assert(is_contiguous_container_asan_correct(v));
58 const std::vector<Nasty, min_allocator<Nasty>> v(100);
59 assert(v.data() == std::addressof(v.front()));
60 assert(is_contiguous_container_asan_correct(v));
63 const std::vector<int, safe_allocator<int>> v;
64 assert(v.data() == 0);
65 assert(is_contiguous_container_asan_correct(v));
68 const std::vector<int, safe_allocator<int>> v(100);
69 assert(v.data() == &v.front());
70 assert(is_contiguous_container_asan_correct(v));
73 const std::vector<Nasty, safe_allocator<Nasty>> v(100);
74 assert(v.data() == std::addressof(v.front()));
75 assert(is_contiguous_container_asan_correct(v));
77 #endif
79 return true;
82 int main(int, char**)
84 tests();
85 #if TEST_STD_VER > 17
86 static_assert(tests());
87 #endif
88 return 0;