[libcxx-commits] [libcxx] [libc++][test] Avoid non-Standard zero-length arrays (PR #74183)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Dec 2 14:40:53 PST 2023
https://github.com/StephanTLavavej updated https://github.com/llvm/llvm-project/pull/74183
>From 4897f1aa31fb928fb2997499153a8907bc7615eb Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Thu, 30 Nov 2023 20:58:04 -0800
Subject: [PATCH 1/6] Avoid non-Standard zero-length arrays.
I'm adding pointers in order to avoid disrupting the following code.
Add `-Wzero-length-array` to `params.py` to prevent future occurrences.
Might need to be clang-formatted.
---
.../random_shuffle.pass.cpp | 4 ++-
.../ranges.transform.binary.iterator.pass.cpp | 12 ++++++---
.../ranges.transform.binary.range.pass.cpp | 12 ++++++---
.../ranges.transform.unary.pass.cpp | 6 +++--
.../alg.ends_with/ranges.ends_with.pass.cpp | 6 +++--
.../alg.equal/ranges.equal.pass.cpp | 25 +++++++++++++------
.../alg.find.end/ranges.find_end.pass.cpp | 12 ++++++---
.../alg.foreach/ranges.for_each.pass.cpp | 7 ++++--
.../alg.foreach/ranges.for_each_n.pass.cpp | 4 ++-
.../alg.search/ranges.search.pass.cpp | 12 ++++++---
.../alg.search/ranges.search_n.pass.cpp | 6 +++--
.../ranges.starts_with.pass.cpp | 12 ++++++---
.../ranges.is_partitioned.pass.cpp | 7 ++++--
.../is.sorted/ranges.is_sorted.pass.cpp | 6 +++--
.../is.sorted/ranges.is_sorted_until.pass.cpp | 6 +++--
libcxx/utils/libcxx/test/params.py | 1 +
16 files changed, 94 insertions(+), 44 deletions(-)
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
index 087a498642881..43932cc2696a4 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -17,6 +17,7 @@
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
#include <algorithm>
+#include <array>
#include <cassert>
#include "test_macros.h"
@@ -26,7 +27,8 @@ template <class Iter>
void
test_with_iterator()
{
- int empty[] = {};
+ std::array<int, 0> empty_arr = {};
+ int* const empty = empty_arr.data();
std::random_shuffle(Iter(empty), Iter(empty));
const int all_elements[] = {1, 2, 3, 4};
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp
index b604263e525d2..74e41293b9f15 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp
@@ -89,7 +89,8 @@ constexpr bool test_iterators() {
}
{ // first range empty
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int b[] = {5, 4, 3, 2, 1};
int c[5];
@@ -103,7 +104,8 @@ constexpr bool test_iterators() {
{ // second range empty
int a[] = {5, 4, 3, 2, 1};
- int b[] = {};
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
int c[5];
auto ret = std::ranges::transform(
@@ -115,8 +117,10 @@ constexpr bool test_iterators() {
}
{ // both ranges empty
- int a[] = {};
- int b[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
int c[5];
auto ret = std::ranges::transform(
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp
index 08ca8aa3fd9ee..feaeafa397c7b 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp
@@ -92,7 +92,8 @@ constexpr bool test_iterators() {
}
{ // first range empty
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int b[] = {5, 4, 3, 2, 1};
int c[5];
@@ -108,7 +109,8 @@ constexpr bool test_iterators() {
{ // second range empty
int a[] = {5, 4, 3, 2, 1};
- int b[] = {};
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
int c[5];
auto range1 = std::ranges::subrange(In1(a), Sent1(In1(a + 5)));
@@ -122,8 +124,10 @@ constexpr bool test_iterators() {
}
{ // both ranges empty
- int a[] = {};
- int b[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
int c[5];
auto range1 = std::ranges::subrange(In1(a), Sent1(In1(a)));
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp
index eeacf83664cfe..c2d59b4e402d6 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp
@@ -108,7 +108,8 @@ constexpr bool test_iterators() {
{ // first range empty
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int b[5];
auto ret = std::ranges::transform(In1(a), Sent1(In1(a)), Out(b), [](int i) { return i * 2; });
assert(base(ret.in) == a);
@@ -116,7 +117,8 @@ constexpr bool test_iterators() {
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int b[5];
auto range = std::ranges::subrange(In1(a), Sent1(In1(a)));
auto ret = std::ranges::transform(range, Out(b), [](int i) { return i * 2; });
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp
index ce4dffffc4763..5fcb6c23dcd4a 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp
@@ -156,7 +156,8 @@ constexpr void test_iterators() {
{ // suffix has zero length
int a[] = {1, 2, 3, 4, 5, 6};
- int p[] = {};
+ std::array<int, 0> p_arr = {};
+ int* const p = p_arr.data();
auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
auto suffix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
{
@@ -170,7 +171,8 @@ constexpr void test_iterators() {
}
{ // range has zero length
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int p[] = {1, 2, 3, 4, 5, 6, 7, 8};
auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto suffix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 8)));
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
index 828f75ea11d35..5e57cfa609433 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
@@ -23,6 +23,7 @@
// Proj1 proj1 = {}, Proj2 proj2 = {});
#include <algorithm>
+#include <array>
#include <cassert>
#include <concepts>
#include <functional>
@@ -200,14 +201,18 @@ constexpr void test_iterators() {
{ // check that two empty ranges work
{
- int a[] = {};
- int b[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a)), Iter2(b), Sent2(Iter2(b)));
assert(ret);
}
{
- int a[] = {};
- int b[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b)));
auto ret = std::ranges::equal(range1, range2);
@@ -217,13 +222,15 @@ constexpr void test_iterators() {
{ // check that it works with the first range empty
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int b[] = {1, 2};
auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a)), Iter2(b), Sent2(Iter2(b + 2)));
assert(!ret);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int b[] = {1, 2};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b + 2)));
@@ -235,13 +242,15 @@ constexpr void test_iterators() {
{ // check that it works with the second range empty
{
int a[] = {1, 2};
- int b[] = {};
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a + 2)), Iter2(b), Sent2(Iter2(b)));
assert(!ret);
}
{
int a[] = {1, 2};
- int b[] = {};
+ std::array<int, 0> b_arr = {};
+ int* const b = b_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 2)));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b)));
auto ret = std::ranges::equal(range1, range2);
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
index d826ff6ddf426..6753ea913a844 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
@@ -182,14 +182,16 @@ constexpr void test_iterators() {
{ // pattern has zero length
{
int a[] = {6, 7, 8};
- int p[] = {};
+ std::array<int, 0> p_arr = {};
+ int* const p = p_arr.data();
auto ret = std::ranges::find_end(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p), Sent2(Iter2(p)));
assert(base(ret.begin()) == a + 3);
assert(base(ret.end()) == a + 3);
}
{
int a[] = {6, 7, 8};
- int p[] = {};
+ std::array<int, 0> p_arr = {};
+ int* const p = p_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
auto ret = std::ranges::find_end(range1, range2);
@@ -200,14 +202,16 @@ constexpr void test_iterators() {
{ // range has zero length
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto ret = std::ranges::find_end(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 3)));
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
index 52b91268edda6..d2b02873b9677 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
@@ -19,6 +19,7 @@
// ranges::for_each(R&& r, Fun f, Proj proj = {});
#include <algorithm>
+#include <array>
#include <ranges>
#include "almost_satisfies_types.h"
@@ -98,11 +99,13 @@ constexpr void test_iterator() {
{ // check that an empty range works
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
std::ranges::for_each(Iter(a), Sent(Iter(a)), [](auto&) { assert(false); });
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
std::ranges::for_each(range, [](auto&) { assert(false); });
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
index 913819979ca1c..2b54de303cd87 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
@@ -16,6 +16,7 @@
// ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {});
#include <algorithm>
+#include <array>
#include <ranges>
#include "almost_satisfies_types.h"
@@ -58,7 +59,8 @@ constexpr void test_iterator() {
}
{ // check that an empty range works
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
std::ranges::for_each_n(Iter(a), 0, [](auto&) { assert(false); });
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
index b35729962492b..0152093d40ca7 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
@@ -183,14 +183,16 @@ constexpr void test_iterators() {
{ // pattern has zero length
{
int a[] = {6, 7, 8};
- int p[] = {};
+ std::array<int, 0> p_arr = {};
+ int* const p = p_arr.data();
auto ret = std::ranges::search(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p), Sent2(Iter2(p)));
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
}
{
int a[] = {6, 7, 8};
- int p[] = {};
+ std::array<int, 0> p_arr = {};
+ int* const p = p_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
auto ret = std::ranges::search(range1, range2);
@@ -201,14 +203,16 @@ constexpr void test_iterators() {
{ // range has zero length
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto ret = std::ranges::search(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 3)));
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
index feca3b276c9a5..dbab7088d28f4 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
@@ -171,13 +171,15 @@ constexpr void test_iterators() {
{ // range has zero length
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto ret = std::ranges::search_n(Iter(a), Sent(Iter(a)), 1, 1);
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::search_n(range, 1, 1);
assert(base(ret.begin()) == a);
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp
index 85c6bf96b2aa5..86f476d75b2e6 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp
@@ -136,14 +136,16 @@ constexpr void test_iterators() {
{ // prefix has zero length
{
int a[] = {1, 2, 3, 4, 5, 6};
- int p[] = {};
+ std::array<int, 0> p_arr = {};
+ int* const p = p_arr.data();
std::same_as<bool> decltype(auto) ret =
std::ranges::starts_with(Iter1(a), Sent1(Iter1(a + 6)), Iter2(p), Sent2(Iter2(p)));
assert(ret);
}
{
int a[] = {1, 2, 3, 4, 5, 6};
- int p[] = {};
+ std::array<int, 0> p_arr = {};
+ int* const p = p_arr.data();
auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
auto prefix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
std::same_as<bool> decltype(auto) ret = std::ranges::starts_with(whole, prefix);
@@ -153,14 +155,16 @@ constexpr void test_iterators() {
{ // range has zero length
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int p[] = {1, 2, 3, 4, 5, 6, 7, 8};
std::same_as<bool> decltype(auto) ret =
std::ranges::starts_with(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 8)));
assert(!ret);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
int p[] = {1, 2, 3, 4, 5, 6, 7, 8};
auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto prefix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 8)));
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
index 72b58f5534140..990ab0959a625 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
@@ -19,6 +19,7 @@
#include <algorithm>
+#include <array>
#include <cassert>
#include "almost_satisfies_types.h"
@@ -131,12 +132,14 @@ constexpr void test_iterators() {
{ // check that an empty range is partitioned
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto ret = std::ranges::is_partitioned(Iter(a), Sent(Iter(a)), [](int i) { return i < 3; });
assert(ret);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::is_partitioned(range, [](int i) { return i < 3; });
assert(ret);
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
index b8831f76c58e5..5bc399d818b6a 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
@@ -109,12 +109,14 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto ret = std::ranges::is_sorted(Iter(a), Sent(Iter(a)));
assert(ret);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::is_sorted(range);
assert(ret);
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
index c5a0fe8831237..9348e63fb93a2 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
@@ -110,12 +110,14 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto ret = std::ranges::is_sorted_until(Iter(a), Sent(Iter(a)));
assert(base(ret) == a);
}
{
- int a[] = {};
+ std::array<int, 0> a_arr = {};
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::is_sorted_until(range);
assert(base(ret) == a);
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 3fedbf972c0c8..ef532adc2cc02 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -48,6 +48,7 @@
# These warnings should be enabled in order to support the MSVC
# team using the test suite; They enable the warnings below and
# expect the test suite to be clean.
+ "-Wzero-length-array",
"-Wsign-compare",
"-Wunused-variable",
"-Wunused-parameter",
>From ca6b5a3d9cff65e2c773e8b5db59b3b6eb380d3e Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Fri, 1 Dec 2023 23:26:57 -0800
Subject: [PATCH 2/6] Apply clang-format from CI.
---
.../random_shuffle.pass.cpp | 20 +++++++++----------
.../alg.equal/ranges.equal.pass.cpp | 16 +++++++--------
.../alg.find.end/ranges.find_end.pass.cpp | 8 ++++----
.../alg.foreach/ranges.for_each.pass.cpp | 4 ++--
.../alg.foreach/ranges.for_each_n.pass.cpp | 2 +-
.../alg.search/ranges.search.pass.cpp | 8 ++++----
.../alg.search/ranges.search_n.pass.cpp | 4 ++--
.../ranges.is_partitioned.pass.cpp | 4 ++--
.../is.sorted/ranges.is_sorted.pass.cpp | 4 ++--
.../is.sorted/ranges.is_sorted_until.pass.cpp | 4 ++--
10 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
index 43932cc2696a4..462816b564bb0 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -27,19 +27,19 @@ template <class Iter>
void
test_with_iterator()
{
- std::array<int, 0> empty_arr = {};
- int* const empty = empty_arr.data();
- std::random_shuffle(Iter(empty), Iter(empty));
+ std::array<int, 0> empty_arr = {};
+ int* const empty = empty_arr.data();
+ std::random_shuffle(Iter(empty), Iter(empty));
- const int all_elements[] = {1, 2, 3, 4};
- int shuffled[] = {1, 2, 3, 4};
- const unsigned size = sizeof(all_elements)/sizeof(all_elements[0]);
+ const int all_elements[] = {1, 2, 3, 4};
+ int shuffled[] = {1, 2, 3, 4};
+ const unsigned size = sizeof(all_elements) / sizeof(all_elements[0]);
- std::random_shuffle(Iter(shuffled), Iter(shuffled+size));
- assert(std::is_permutation(shuffled, shuffled+size, all_elements));
+ std::random_shuffle(Iter(shuffled), Iter(shuffled + size));
+ assert(std::is_permutation(shuffled, shuffled + size, all_elements));
- std::random_shuffle(Iter(shuffled), Iter(shuffled+size));
- assert(std::is_permutation(shuffled, shuffled+size, all_elements));
+ std::random_shuffle(Iter(shuffled), Iter(shuffled + size));
+ assert(std::is_permutation(shuffled, shuffled + size, all_elements));
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
index 5e57cfa609433..2266489987f3a 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
@@ -202,17 +202,17 @@ constexpr void test_iterators() {
{ // check that two empty ranges work
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ int* const b = b_arr.data();
auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a)), Iter2(b), Sent2(Iter2(b)));
assert(ret);
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ int* const b = b_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b)));
auto ret = std::ranges::equal(range1, range2);
@@ -223,14 +223,14 @@ constexpr void test_iterators() {
{ // check that it works with the first range empty
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
int b[] = {1, 2};
auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a)), Iter2(b), Sent2(Iter2(b + 2)));
assert(!ret);
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
int b[] = {1, 2};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b + 2)));
@@ -243,14 +243,14 @@ constexpr void test_iterators() {
{
int a[] = {1, 2};
std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ int* const b = b_arr.data();
auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a + 2)), Iter2(b), Sent2(Iter2(b)));
assert(!ret);
}
{
int a[] = {1, 2};
std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ int* const b = b_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 2)));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b)));
auto ret = std::ranges::equal(range1, range2);
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
index 6753ea913a844..ed55b3c1bb42f 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
@@ -183,7 +183,7 @@ constexpr void test_iterators() {
{
int a[] = {6, 7, 8};
std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ int* const p = p_arr.data();
auto ret = std::ranges::find_end(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p), Sent2(Iter2(p)));
assert(base(ret.begin()) == a + 3);
assert(base(ret.end()) == a + 3);
@@ -191,7 +191,7 @@ constexpr void test_iterators() {
{
int a[] = {6, 7, 8};
std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ int* const p = p_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
auto ret = std::ranges::find_end(range1, range2);
@@ -203,7 +203,7 @@ constexpr void test_iterators() {
{ // range has zero length
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto ret = std::ranges::find_end(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 3)));
assert(base(ret.begin()) == a);
@@ -211,7 +211,7 @@ constexpr void test_iterators() {
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
index d2b02873b9677..2e631a72725ff 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
@@ -100,12 +100,12 @@ constexpr void test_iterator() {
{ // check that an empty range works
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
std::ranges::for_each(Iter(a), Sent(Iter(a)), [](auto&) { assert(false); });
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
std::ranges::for_each(range, [](auto&) { assert(false); });
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
index 2b54de303cd87..4d4b743ffd1f4 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
@@ -60,7 +60,7 @@ constexpr void test_iterator() {
{ // check that an empty range works
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
std::ranges::for_each_n(Iter(a), 0, [](auto&) { assert(false); });
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
index 0152093d40ca7..97332408f626a 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
@@ -184,7 +184,7 @@ constexpr void test_iterators() {
{
int a[] = {6, 7, 8};
std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ int* const p = p_arr.data();
auto ret = std::ranges::search(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p), Sent2(Iter2(p)));
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
@@ -192,7 +192,7 @@ constexpr void test_iterators() {
{
int a[] = {6, 7, 8};
std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ int* const p = p_arr.data();
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
auto ret = std::ranges::search(range1, range2);
@@ -204,7 +204,7 @@ constexpr void test_iterators() {
{ // range has zero length
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto ret = std::ranges::search(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 3)));
assert(base(ret.begin()) == a);
@@ -212,7 +212,7 @@ constexpr void test_iterators() {
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
int p[] = {6, 7, 8};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
index dbab7088d28f4..4122db99ff8cb 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
@@ -172,14 +172,14 @@ constexpr void test_iterators() {
{ // range has zero length
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto ret = std::ranges::search_n(Iter(a), Sent(Iter(a)), 1, 1);
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::search_n(range, 1, 1);
assert(base(ret.begin()) == a);
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
index 990ab0959a625..64fb1f8cf89f3 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
@@ -133,13 +133,13 @@ constexpr void test_iterators() {
{ // check that an empty range is partitioned
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto ret = std::ranges::is_partitioned(Iter(a), Sent(Iter(a)), [](int i) { return i < 3; });
assert(ret);
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::is_partitioned(range, [](int i) { return i < 3; });
assert(ret);
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
index 5bc399d818b6a..57a968d770ac6 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
@@ -110,13 +110,13 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto ret = std::ranges::is_sorted(Iter(a), Sent(Iter(a)));
assert(ret);
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::is_sorted(range);
assert(ret);
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
index 9348e63fb93a2..ec2cb4cf46f10 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
@@ -111,13 +111,13 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto ret = std::ranges::is_sorted_until(Iter(a), Sent(Iter(a)));
assert(base(ret) == a);
}
{
std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ int* const a = a_arr.data();
auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
auto ret = std::ranges::is_sorted_until(range);
assert(base(ret) == a);
>From f76001746cbc9ff89c735957abecc7a8041f7adc Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Fri, 1 Dec 2023 23:57:27 -0800
Subject: [PATCH 3/6] Drop attempt to add -Wzero-length-array to params.py.
---
libcxx/utils/libcxx/test/params.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index ef532adc2cc02..3fedbf972c0c8 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -48,7 +48,6 @@
# These warnings should be enabled in order to support the MSVC
# team using the test suite; They enable the warnings below and
# expect the test suite to be clean.
- "-Wzero-length-array",
"-Wsign-compare",
"-Wunused-variable",
"-Wunused-parameter",
>From 408768b015ab2e5ffe9c63414e583a9d852ecd9c Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Wed, 29 Nov 2023 21:46:13 -0800
Subject: [PATCH 4/6] Fix comment typos.
---
libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py | 2 +-
.../unique.ptr.observers/op_subscript.runtime.pass.cpp | 2 +-
libcxx/utils/libcxx/test/params.py | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
index ddb58a872d4c1..07154d001d3a1 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
@@ -76,7 +76,7 @@ def invoke(self, arg, from_tty):
except RuntimeError as e:
# At this point, lots of different things could be wrong, so don't try to
# recover or figure it out. Don't exit either, because then it's
- # impossible debug the framework itself.
+ # impossible to debug the framework itself.
print("FAIL: Something is wrong in the test framework.")
print(str(e))
test_failures += 1
diff --git a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp
index 28af75afca419..fbb4dbc6e0308 100644
--- a/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp
+++ b/libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/op_subscript.runtime.pass.cpp
@@ -15,7 +15,7 @@
#include <memory>
#include <cassert>
-// TODO: Move TEST_IS_CONSTANT_EVALUATED into it's own header
+// TODO: Move TEST_IS_CONSTANT_EVALUATED into its own header
#include <type_traits>
#include "test_macros.h"
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 3fedbf972c0c8..4e209901f43be 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -39,7 +39,7 @@
"-Wno-literal-suffix", # GCC
"-Wno-user-defined-literals", # Clang
# GCC warns about this when TEST_IS_CONSTANT_EVALUATED is used on a non-constexpr
- # function. (This mostely happens in C++11 mode.)
+ # function. (This mostly happens in C++11 mode.)
# TODO(mordante) investigate a solution for this issue.
"-Wno-tautological-compare",
# -Wstringop-overread and -Wstringop-overflow seem to be a bit buggy currently
>From f31e6201d2b9c185043a76c5c97ae52443284b3e Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sat, 2 Dec 2023 14:25:07 -0800
Subject: [PATCH 5/6] Drop the array/pointer dance.
---
.../random_shuffle.pass.cpp | 5 +--
.../ranges.transform.binary.iterator.pass.cpp | 26 ++++++-------
.../ranges.transform.binary.range.pass.cpp | 28 ++++++--------
.../ranges.transform.unary.pass.cpp | 14 +++----
.../alg.ends_with/ranges.ends_with.pass.cpp | 10 ++---
.../alg.equal/ranges.equal.pass.cpp | 38 ++++++++-----------
.../alg.find.end/ranges.find_end.pass.cpp | 28 ++++++--------
.../alg.foreach/ranges.for_each.pass.cpp | 10 ++---
.../alg.foreach/ranges.for_each_n.pass.cpp | 5 +--
.../alg.search/ranges.search.pass.cpp | 28 ++++++--------
.../alg.search/ranges.search_n.pass.cpp | 18 ++++-----
.../ranges.starts_with.pass.cpp | 20 ++++------
.../ranges.is_partitioned.pass.cpp | 10 ++---
.../is.sorted/ranges.is_sorted.pass.cpp | 10 ++---
.../is.sorted/ranges.is_sorted_until.pass.cpp | 14 +++----
15 files changed, 110 insertions(+), 154 deletions(-)
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
index 462816b564bb0..90132ba6edf86 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -27,9 +27,8 @@ template <class Iter>
void
test_with_iterator()
{
- std::array<int, 0> empty_arr = {};
- int* const empty = empty_arr.data();
- std::random_shuffle(Iter(empty), Iter(empty));
+ std::array<int, 0> empty = {};
+ std::random_shuffle(Iter(empty.data()), Iter(empty.data()));
const int all_elements[] = {1, 2, 3, 4};
int shuffled[] = {1, 2, 3, 4};
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp
index 74e41293b9f15..d7511257cd239 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.iterator.pass.cpp
@@ -89,45 +89,41 @@ constexpr bool test_iterators() {
}
{ // first range empty
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int b[] = {5, 4, 3, 2, 1};
int c[5];
auto ret = std::ranges::transform(
- In1(a), Sent1(In1(a)), In2(b), Sent2(In2(b + 5)), Out(c), [](int i, int j) { return i + j; });
+ In1(a.data()), Sent1(In1(a.data())), In2(b), Sent2(In2(b + 5)), Out(c), [](int i, int j) { return i + j; });
- assert(base(ret.in1) == a);
+ assert(base(ret.in1) == a.data());
assert(base(ret.in2) == b);
assert(base(ret.out) == c);
}
{ // second range empty
int a[] = {5, 4, 3, 2, 1};
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ std::array<int, 0> b = {};
int c[5];
auto ret = std::ranges::transform(
- In1(a), Sent1(In1(a + 5)), In2(b), Sent2(In2(b)), Out(c), [](int i, int j) { return i + j; });
+ In1(a), Sent1(In1(a + 5)), In2(b.data()), Sent2(In2(b.data())), Out(c), [](int i, int j) { return i + j; });
assert(base(ret.in1) == a);
- assert(base(ret.in2) == b);
+ assert(base(ret.in2) == b.data());
assert(base(ret.out) == c);
}
{ // both ranges empty
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ std::array<int, 0> a = {};
+ std::array<int, 0> b = {};
int c[5];
auto ret = std::ranges::transform(
- In1(a), Sent1(In1(a)), In2(b), Sent2(In2(b)), Out(c), [](int i, int j) { return i + j; });
+ In1(a.data()), Sent1(In1(a.data())), In2(b.data()), Sent2(In2(b.data())), Out(c), [](int i, int j) { return i + j; });
- assert(base(ret.in1) == a);
- assert(base(ret.in2) == b);
+ assert(base(ret.in1) == a.data());
+ assert(base(ret.in2) == b.data());
assert(base(ret.out) == c);
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp
index feaeafa397c7b..bdefaa02f04f8 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.binary.range.pass.cpp
@@ -92,51 +92,47 @@ constexpr bool test_iterators() {
}
{ // first range empty
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int b[] = {5, 4, 3, 2, 1};
int c[5];
- auto range1 = std::ranges::subrange(In1(a), Sent1(In1(a)));
+ auto range1 = std::ranges::subrange(In1(a.data()), Sent1(In1(a.data())));
auto range2 = std::ranges::subrange(In2(b), Sent2(In2(b + 5)));
auto ret = std::ranges::transform(range1, range2, Out(c), [](int i, int j) { return i + j; });
- assert(base(ret.in1) == a);
+ assert(base(ret.in1) == a.data());
assert(base(ret.in2) == b);
assert(base(ret.out) == c);
}
{ // second range empty
int a[] = {5, 4, 3, 2, 1};
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ std::array<int, 0> b = {};
int c[5];
auto range1 = std::ranges::subrange(In1(a), Sent1(In1(a + 5)));
- auto range2 = std::ranges::subrange(In2(b), Sent2(In2(b)));
+ auto range2 = std::ranges::subrange(In2(b.data()), Sent2(In2(b.data())));
auto ret = std::ranges::transform(range1, range2, Out(c), [](int i, int j) { return i + j; });
assert(base(ret.in1) == a);
- assert(base(ret.in2) == b);
+ assert(base(ret.in2) == b.data());
assert(base(ret.out) == c);
}
{ // both ranges empty
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ std::array<int, 0> a = {};
+ std::array<int, 0> b = {};
int c[5];
- auto range1 = std::ranges::subrange(In1(a), Sent1(In1(a)));
- auto range2 = std::ranges::subrange(In2(b), Sent2(In2(b)));
+ auto range1 = std::ranges::subrange(In1(a.data()), Sent1(In1(a.data())));
+ auto range2 = std::ranges::subrange(In2(b.data()), Sent2(In2(b.data())));
auto ret = std::ranges::transform(range1, range2, Out(c), [](int i, int j) { return i + j; });
- assert(base(ret.in1) == a);
- assert(base(ret.in2) == b);
+ assert(base(ret.in1) == a.data());
+ assert(base(ret.in2) == b.data());
assert(base(ret.out) == c);
}
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp
index c2d59b4e402d6..d6c0bb65acc88 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.unary.pass.cpp
@@ -108,21 +108,19 @@ constexpr bool test_iterators() {
{ // first range empty
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int b[5];
- auto ret = std::ranges::transform(In1(a), Sent1(In1(a)), Out(b), [](int i) { return i * 2; });
- assert(base(ret.in) == a);
+ auto ret = std::ranges::transform(In1(a.data()), Sent1(In1(a.data())), Out(b), [](int i) { return i * 2; });
+ assert(base(ret.in) == a.data());
assert(base(ret.out) == b);
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int b[5];
- auto range = std::ranges::subrange(In1(a), Sent1(In1(a)));
+ auto range = std::ranges::subrange(In1(a.data()), Sent1(In1(a.data())));
auto ret = std::ranges::transform(range, Out(b), [](int i) { return i * 2; });
- assert(base(ret.in) == a);
+ assert(base(ret.in) == a.data());
assert(base(ret.out) == b);
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp
index 5fcb6c23dcd4a..685bd692422ac 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.ends_with/ranges.ends_with.pass.cpp
@@ -156,10 +156,9 @@ constexpr void test_iterators() {
{ // suffix has zero length
int a[] = {1, 2, 3, 4, 5, 6};
- std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ std::array<int, 0> p = {};
auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
- auto suffix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
+ auto suffix = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
{
bool ret = std::ranges::ends_with(whole.begin(), whole.end(), suffix.begin(), suffix.end());
assert(ret);
@@ -171,10 +170,9 @@ constexpr void test_iterators() {
}
{ // range has zero length
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int p[] = {1, 2, 3, 4, 5, 6, 7, 8};
- auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+ auto whole = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto suffix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 8)));
{
bool ret = std::ranges::ends_with(whole.begin(), whole.end(), suffix.begin(), suffix.end());
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
index 2266489987f3a..f6c808c61a97a 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
@@ -201,20 +201,16 @@ constexpr void test_iterators() {
{ // check that two empty ranges work
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
- auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a)), Iter2(b), Sent2(Iter2(b)));
+ std::array<int, 0> a = {};
+ std::array<int, 0> b = {};
+ auto ret = std::ranges::equal(Iter1(a.data()), Sent1(Iter1(a.data())), Iter2(b.data()), Sent2(Iter2(b.data())));
assert(ret);
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
- auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
- auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b)));
+ std::array<int, 0> a = {};
+ std::array<int, 0> b = {};
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
+ auto range2 = std::ranges::subrange(Iter2(b.data()), Sent2(Iter2(b.data())));
auto ret = std::ranges::equal(range1, range2);
assert(ret);
}
@@ -222,17 +218,15 @@ constexpr void test_iterators() {
{ // check that it works with the first range empty
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int b[] = {1, 2};
- auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a)), Iter2(b), Sent2(Iter2(b + 2)));
+ auto ret = std::ranges::equal(Iter1(a.data()), Sent1(Iter1(a.data())), Iter2(b), Sent2(Iter2(b + 2)));
assert(!ret);
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int b[] = {1, 2};
- auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b + 2)));
auto ret = std::ranges::equal(range1, range2);
assert(!ret);
@@ -242,17 +236,15 @@ constexpr void test_iterators() {
{ // check that it works with the second range empty
{
int a[] = {1, 2};
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
- auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a + 2)), Iter2(b), Sent2(Iter2(b)));
+ std::array<int, 0> b = {};
+ auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a + 2)), Iter2(b.data()), Sent2(Iter2(b.data())));
assert(!ret);
}
{
int a[] = {1, 2};
- std::array<int, 0> b_arr = {};
- int* const b = b_arr.data();
+ std::array<int, 0> b = {};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 2)));
- auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b)));
+ auto range2 = std::ranges::subrange(Iter2(b.data()), Sent2(Iter2(b.data())));
auto ret = std::ranges::equal(range1, range2);
assert(!ret);
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
index ed55b3c1bb42f..2596ffc71641d 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
@@ -182,18 +182,16 @@ constexpr void test_iterators() {
{ // pattern has zero length
{
int a[] = {6, 7, 8};
- std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
- auto ret = std::ranges::find_end(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p), Sent2(Iter2(p)));
+ std::array<int, 0> p = {};
+ auto ret = std::ranges::find_end(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p.data()), Sent2(Iter2(p.data())));
assert(base(ret.begin()) == a + 3);
assert(base(ret.end()) == a + 3);
}
{
int a[] = {6, 7, 8};
- std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ std::array<int, 0> p = {};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
- auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
+ auto range2 = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
auto ret = std::ranges::find_end(range1, range2);
assert(base(ret.begin()) == a + 3);
assert(base(ret.end()) == a + 3);
@@ -202,22 +200,20 @@ constexpr void test_iterators() {
{ // range has zero length
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int p[] = {6, 7, 8};
- auto ret = std::ranges::find_end(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 3)));
- assert(base(ret.begin()) == a);
- assert(base(ret.end()) == a);
+ auto ret = std::ranges::find_end(Iter1(a.data()), Sent1(Iter1(a.data())), Iter2(p), Sent2(Iter2(p + 3)));
+ assert(base(ret.begin()) == a.data());
+ assert(base(ret.end()) == a.data());
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int p[] = {6, 7, 8};
- auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
auto ret = std::ranges::find_end(range1, range2);
- assert(base(ret.begin()) == a);
- assert(base(ret.end()) == a);
+ assert(base(ret.begin()) == a.data());
+ assert(base(ret.end()) == a.data());
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
index 2e631a72725ff..e13d19afd92b4 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
@@ -99,14 +99,12 @@ constexpr void test_iterator() {
{ // check that an empty range works
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- std::ranges::for_each(Iter(a), Sent(Iter(a)), [](auto&) { assert(false); });
+ std::array<int, 0> a = {};
+ std::ranges::for_each(Iter(a.data()), Sent(Iter(a.data())), [](auto&) { assert(false); });
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+ std::array<int, 0> a = {};
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
std::ranges::for_each(range, [](auto&) { assert(false); });
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
index 4d4b743ffd1f4..d4b2d053d08ce 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each_n.pass.cpp
@@ -59,9 +59,8 @@ constexpr void test_iterator() {
}
{ // check that an empty range works
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- std::ranges::for_each_n(Iter(a), 0, [](auto&) { assert(false); });
+ std::array<int, 0> a = {};
+ std::ranges::for_each_n(Iter(a.data()), 0, [](auto&) { assert(false); });
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
index 97332408f626a..162e07eb71da9 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
@@ -183,18 +183,16 @@ constexpr void test_iterators() {
{ // pattern has zero length
{
int a[] = {6, 7, 8};
- std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
- auto ret = std::ranges::search(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p), Sent2(Iter2(p)));
+ std::array<int, 0> p = {};
+ auto ret = std::ranges::search(Iter1(a), Sent1(Iter1(a + 3)), Iter2(p.data()), Sent2(Iter2(p.data())));
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
}
{
int a[] = {6, 7, 8};
- std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ std::array<int, 0> p = {};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
- auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
+ auto range2 = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
auto ret = std::ranges::search(range1, range2);
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
@@ -203,22 +201,20 @@ constexpr void test_iterators() {
{ // range has zero length
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int p[] = {6, 7, 8};
- auto ret = std::ranges::search(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 3)));
- assert(base(ret.begin()) == a);
- assert(base(ret.end()) == a);
+ auto ret = std::ranges::search(Iter1(a.data()), Sent1(Iter1(a.data())), Iter2(p), Sent2(Iter2(p + 3)));
+ assert(base(ret.begin()) == a.data());
+ assert(base(ret.end()) == a.data());
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int p[] = {6, 7, 8};
- auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
auto ret = std::ranges::search(range1, range2);
- assert(base(ret.begin()) == a);
- assert(base(ret.end()) == a);
+ assert(base(ret.begin()) == a.data());
+ assert(base(ret.end()) == a.data());
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
index 4122db99ff8cb..6fdb882f13919 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
@@ -171,19 +171,17 @@ constexpr void test_iterators() {
{ // range has zero length
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto ret = std::ranges::search_n(Iter(a), Sent(Iter(a)), 1, 1);
- assert(base(ret.begin()) == a);
- assert(base(ret.end()) == a);
+ std::array<int, 0> a = {};
+ auto ret = std::ranges::search_n(Iter(a.data()), Sent(Iter(a.data())), 1, 1);
+ assert(base(ret.begin()) == a.data());
+ assert(base(ret.end()) == a.data());
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+ std::array<int, 0> a = {};
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::search_n(range, 1, 1);
- assert(base(ret.begin()) == a);
- assert(base(ret.end()) == a);
+ assert(base(ret.begin()) == a.data());
+ assert(base(ret.end()) == a.data());
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp
index 86f476d75b2e6..0f2284edde81c 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.starts_with/ranges.starts_with.pass.cpp
@@ -136,18 +136,16 @@ constexpr void test_iterators() {
{ // prefix has zero length
{
int a[] = {1, 2, 3, 4, 5, 6};
- std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ std::array<int, 0> p = {};
std::same_as<bool> decltype(auto) ret =
- std::ranges::starts_with(Iter1(a), Sent1(Iter1(a + 6)), Iter2(p), Sent2(Iter2(p)));
+ std::ranges::starts_with(Iter1(a), Sent1(Iter1(a + 6)), Iter2(p.data()), Sent2(Iter2(p.data())));
assert(ret);
}
{
int a[] = {1, 2, 3, 4, 5, 6};
- std::array<int, 0> p_arr = {};
- int* const p = p_arr.data();
+ std::array<int, 0> p = {};
auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 6)));
- auto prefix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p)));
+ auto prefix = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
std::same_as<bool> decltype(auto) ret = std::ranges::starts_with(whole, prefix);
assert(ret);
}
@@ -155,18 +153,16 @@ constexpr void test_iterators() {
{ // range has zero length
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int p[] = {1, 2, 3, 4, 5, 6, 7, 8};
std::same_as<bool> decltype(auto) ret =
- std::ranges::starts_with(Iter1(a), Sent1(Iter1(a)), Iter2(p), Sent2(Iter2(p + 8)));
+ std::ranges::starts_with(Iter1(a.data()), Sent1(Iter1(a.data())), Iter2(p), Sent2(Iter2(p + 8)));
assert(!ret);
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
+ std::array<int, 0> a = {};
int p[] = {1, 2, 3, 4, 5, 6, 7, 8};
- auto whole = std::ranges::subrange(Iter1(a), Sent1(Iter1(a)));
+ auto whole = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto prefix = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 8)));
std::same_as<bool> decltype(auto) ret = std::ranges::starts_with(whole, prefix);
assert(!ret);
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
index 64fb1f8cf89f3..1c7ce93d52cdc 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
@@ -132,15 +132,13 @@ constexpr void test_iterators() {
{ // check that an empty range is partitioned
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto ret = std::ranges::is_partitioned(Iter(a), Sent(Iter(a)), [](int i) { return i < 3; });
+ std::array<int, 0> a = {};
+ auto ret = std::ranges::is_partitioned(Iter(a.data()), Sent(Iter(a.data())), [](int i) { return i < 3; });
assert(ret);
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+ std::array<int, 0> a = {};
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::is_partitioned(range, [](int i) { return i < 3; });
assert(ret);
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
index 57a968d770ac6..c29abf8dfba47 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
@@ -109,15 +109,13 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto ret = std::ranges::is_sorted(Iter(a), Sent(Iter(a)));
+ std::array<int, 0> a = {};
+ auto ret = std::ranges::is_sorted(Iter(a.data()), Sent(Iter(a.data())));
assert(ret);
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+ std::array<int, 0> a = {};
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::is_sorted(range);
assert(ret);
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
index ec2cb4cf46f10..43bf8b92b7ff6 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
@@ -110,17 +110,15 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto ret = std::ranges::is_sorted_until(Iter(a), Sent(Iter(a)));
- assert(base(ret) == a);
+ std::array<int, 0> a = {};
+ auto ret = std::ranges::is_sorted_until(Iter(a.data()), Sent(Iter(a.data())));
+ assert(base(ret) == a.data());
}
{
- std::array<int, 0> a_arr = {};
- int* const a = a_arr.data();
- auto range = std::ranges::subrange(Iter(a), Sent(Iter(a)));
+ std::array<int, 0> a = {};
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::is_sorted_until(range);
- assert(base(ret) == a);
+ assert(base(ret) == a.data());
}
}
>From b88aa42d7acd35aa85273662c1a440cc4f0af43f Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sat, 2 Dec 2023 14:40:13 -0800
Subject: [PATCH 6/6] Apply CI clang-format again.
---
.../alg.nonmodifying/alg.equal/ranges.equal.pass.cpp | 12 ++++++------
.../alg.find.end/ranges.find_end.pass.cpp | 4 ++--
.../alg.foreach/ranges.for_each.pass.cpp | 2 +-
.../alg.search/ranges.search.pass.cpp | 4 ++--
.../alg.search/ranges.search_n.pass.cpp | 4 ++--
.../alg.partitions/ranges.is_partitioned.pass.cpp | 2 +-
.../alg.sort/is.sorted/ranges.is_sorted.pass.cpp | 4 ++--
.../is.sorted/ranges.is_sorted_until.pass.cpp | 4 ++--
8 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
index f6c808c61a97a..f36cd2e089655 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.equal/ranges.equal.pass.cpp
@@ -209,8 +209,8 @@ constexpr void test_iterators() {
{
std::array<int, 0> a = {};
std::array<int, 0> b = {};
- auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
- auto range2 = std::ranges::subrange(Iter2(b.data()), Sent2(Iter2(b.data())));
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
+ auto range2 = std::ranges::subrange(Iter2(b.data()), Sent2(Iter2(b.data())));
auto ret = std::ranges::equal(range1, range2);
assert(ret);
}
@@ -220,13 +220,13 @@ constexpr void test_iterators() {
{
std::array<int, 0> a = {};
int b[] = {1, 2};
- auto ret = std::ranges::equal(Iter1(a.data()), Sent1(Iter1(a.data())), Iter2(b), Sent2(Iter2(b + 2)));
+ auto ret = std::ranges::equal(Iter1(a.data()), Sent1(Iter1(a.data())), Iter2(b), Sent2(Iter2(b + 2)));
assert(!ret);
}
{
std::array<int, 0> a = {};
int b[] = {1, 2};
- auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto range2 = std::ranges::subrange(Iter2(b), Sent2(Iter2(b + 2)));
auto ret = std::ranges::equal(range1, range2);
assert(!ret);
@@ -237,14 +237,14 @@ constexpr void test_iterators() {
{
int a[] = {1, 2};
std::array<int, 0> b = {};
- auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a + 2)), Iter2(b.data()), Sent2(Iter2(b.data())));
+ auto ret = std::ranges::equal(Iter1(a), Sent1(Iter1(a + 2)), Iter2(b.data()), Sent2(Iter2(b.data())));
assert(!ret);
}
{
int a[] = {1, 2};
std::array<int, 0> b = {};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 2)));
- auto range2 = std::ranges::subrange(Iter2(b.data()), Sent2(Iter2(b.data())));
+ auto range2 = std::ranges::subrange(Iter2(b.data()), Sent2(Iter2(b.data())));
auto ret = std::ranges::equal(range1, range2);
assert(!ret);
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
index 2596ffc71641d..deaec0b6ebb62 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.find.end/ranges.find_end.pass.cpp
@@ -191,7 +191,7 @@ constexpr void test_iterators() {
int a[] = {6, 7, 8};
std::array<int, 0> p = {};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
- auto range2 = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
+ auto range2 = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
auto ret = std::ranges::find_end(range1, range2);
assert(base(ret.begin()) == a + 3);
assert(base(ret.end()) == a + 3);
@@ -209,7 +209,7 @@ constexpr void test_iterators() {
{
std::array<int, 0> a = {};
int p[] = {6, 7, 8};
- auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
auto ret = std::ranges::find_end(range1, range2);
assert(base(ret.begin()) == a.data());
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
index e13d19afd92b4..8b9b6e82cbcb2 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.foreach/ranges.for_each.pass.cpp
@@ -104,7 +104,7 @@ constexpr void test_iterator() {
}
{
std::array<int, 0> a = {};
- auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
std::ranges::for_each(range, [](auto&) { assert(false); });
}
}
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
index 162e07eb71da9..8a706071f5130 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search.pass.cpp
@@ -192,7 +192,7 @@ constexpr void test_iterators() {
int a[] = {6, 7, 8};
std::array<int, 0> p = {};
auto range1 = std::ranges::subrange(Iter1(a), Sent1(Iter1(a + 3)));
- auto range2 = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
+ auto range2 = std::ranges::subrange(Iter2(p.data()), Sent2(Iter2(p.data())));
auto ret = std::ranges::search(range1, range2);
assert(base(ret.begin()) == a);
assert(base(ret.end()) == a);
@@ -210,7 +210,7 @@ constexpr void test_iterators() {
{
std::array<int, 0> a = {};
int p[] = {6, 7, 8};
- auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
+ auto range1 = std::ranges::subrange(Iter1(a.data()), Sent1(Iter1(a.data())));
auto range2 = std::ranges::subrange(Iter2(p), Sent2(Iter2(p + 3)));
auto ret = std::ranges::search(range1, range2);
assert(base(ret.begin()) == a.data());
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
index 6fdb882f13919..2f2e436c79130 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/ranges.search_n.pass.cpp
@@ -172,13 +172,13 @@ constexpr void test_iterators() {
{ // range has zero length
{
std::array<int, 0> a = {};
- auto ret = std::ranges::search_n(Iter(a.data()), Sent(Iter(a.data())), 1, 1);
+ auto ret = std::ranges::search_n(Iter(a.data()), Sent(Iter(a.data())), 1, 1);
assert(base(ret.begin()) == a.data());
assert(base(ret.end()) == a.data());
}
{
std::array<int, 0> a = {};
- auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::search_n(range, 1, 1);
assert(base(ret.begin()) == a.data());
assert(base(ret.end()) == a.data());
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
index 1c7ce93d52cdc..8b91fb268cbf8 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.partitions/ranges.is_partitioned.pass.cpp
@@ -138,7 +138,7 @@ constexpr void test_iterators() {
}
{
std::array<int, 0> a = {};
- auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::is_partitioned(range, [](int i) { return i < 3; });
assert(ret);
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
index c29abf8dfba47..4907b10b9cb2f 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted.pass.cpp
@@ -110,12 +110,12 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
std::array<int, 0> a = {};
- auto ret = std::ranges::is_sorted(Iter(a.data()), Sent(Iter(a.data())));
+ auto ret = std::ranges::is_sorted(Iter(a.data()), Sent(Iter(a.data())));
assert(ret);
}
{
std::array<int, 0> a = {};
- auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::is_sorted(range);
assert(ret);
}
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
index 43bf8b92b7ff6..873a1c9cc543d 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/is.sorted/ranges.is_sorted_until.pass.cpp
@@ -111,12 +111,12 @@ constexpr void test_iterators() {
{ // check that an empty range works
{
std::array<int, 0> a = {};
- auto ret = std::ranges::is_sorted_until(Iter(a.data()), Sent(Iter(a.data())));
+ auto ret = std::ranges::is_sorted_until(Iter(a.data()), Sent(Iter(a.data())));
assert(base(ret) == a.data());
}
{
std::array<int, 0> a = {};
- auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
+ auto range = std::ranges::subrange(Iter(a.data()), Sent(Iter(a.data())));
auto ret = std::ranges::is_sorted_until(range);
assert(base(ret) == a.data());
}
More information about the libcxx-commits
mailing list