Skip to content

Commit dedb296

Browse files
committed
[libc++][C++03] Remove code in the C++03-specific tests that is guarded on the language version
1 parent bb78728 commit dedb296

38 files changed

+3
-1251
lines changed

libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,5 @@ int main(int, char**)
4141
#endif // !defined(TEST_HAS_NO_INT128)
4242
}
4343

44-
#if TEST_STD_VER >= 11
45-
{
46-
static_assert(test<char>(), "");
47-
static_assert(test<int>(), "");
48-
static_assert(test<long>(), "");
49-
static_assert(test<std::size_t>(), "");
50-
#if !defined(TEST_HAS_NO_INT128)
51-
static_assert(test<__int128_t>(), "");
52-
#endif // !defined(TEST_HAS_NO_INT128)
53-
}
54-
#endif // TEST_STD_VER >= 11
55-
5644
return 0;
5745
}

libcxx/test/libcxx-03/algorithms/robust_against_copying_comparators.pass.cpp

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,6 @@ struct BinaryTransform {
8282
TEST_CONSTEXPR T operator()(T, T) const { return 0; }
8383
};
8484

85-
#if TEST_STD_VER > 17
86-
template <class T>
87-
struct ThreeWay {
88-
int* copies_;
89-
constexpr explicit ThreeWay(int* copies) : copies_(copies) {}
90-
constexpr ThreeWay(const ThreeWay& rhs) : copies_(rhs.copies_) { *copies_ += 1; }
91-
constexpr ThreeWay& operator=(const ThreeWay&) = default;
92-
constexpr std::strong_ordering operator()(T, T) const { return std::strong_ordering::equal; }
93-
};
94-
#endif
95-
9685
template <class T>
9786
TEST_CONSTEXPR_CXX20 bool all_the_algorithms() {
9887
T a[10] = {};
@@ -109,28 +98,14 @@ TEST_CONSTEXPR_CXX20 bool all_the_algorithms() {
10998
int copies = 0;
11099
(void)std::adjacent_find(first, last, Equal<T>(&copies));
111100
assert(copies == 0);
112-
#if TEST_STD_VER >= 11
113-
(void)std::all_of(first, last, UnaryTrue<T>(&copies));
114-
assert(copies == 0);
115-
(void)std::any_of(first, last, UnaryTrue<T>(&copies));
116-
assert(copies == 0);
117-
#endif
118101
(void)std::binary_search(first, last, value, Less<T>(&copies));
119102
assert(copies == 0);
120-
#if TEST_STD_VER > 17
121-
(void)std::clamp(value, value, value, Less<T>(&copies));
122-
assert(copies == 0);
123-
#endif
124103
(void)std::count_if(first, last, UnaryTrue<T>(&copies));
125104
assert(copies == 0);
126105
(void)std::copy_if(first, last, first2, UnaryTrue<T>(&copies));
127106
assert(copies == 0);
128107
(void)std::equal(first, last, first2, Equal<T>(&copies));
129108
assert(copies == 0);
130-
#if TEST_STD_VER > 11
131-
(void)std::equal(first, last, first2, last2, Equal<T>(&copies));
132-
assert(copies == 0);
133-
#endif
134109
(void)std::equal_range(first, last, value, Less<T>(&copies));
135110
assert(copies == 0);
136111
(void)std::find_end(first, last, first2, mid2, Equal<T>(&copies));
@@ -144,10 +119,6 @@ TEST_CONSTEXPR_CXX20 bool all_the_algorithms() {
144119
(void)std::for_each(first, last, UnaryVoid<T>(&copies));
145120
assert(copies == 1);
146121
copies = 0;
147-
#if TEST_STD_VER > 14
148-
(void)std::for_each_n(first, count, UnaryVoid<T>(&copies));
149-
assert(copies == 0);
150-
#endif
151122
(void)std::generate(first, last, NullaryValue<T>(&copies));
152123
assert(copies == 0);
153124
(void)std::generate_n(first, count, NullaryValue<T>(&copies));
@@ -162,10 +133,6 @@ TEST_CONSTEXPR_CXX20 bool all_the_algorithms() {
162133
assert(copies == 0);
163134
(void)std::is_permutation(first, last, first2, Equal<T>(&copies));
164135
assert(copies == 0);
165-
#if TEST_STD_VER > 11
166-
(void)std::is_permutation(first, last, first2, last2, Equal<T>(&copies));
167-
assert(copies == 0);
168-
#endif
169136
(void)std::is_sorted(first, last, Less<T>(&copies));
170137
assert(copies == 0);
171138
(void)std::is_sorted_until(first, last, Less<T>(&copies));
@@ -176,52 +143,28 @@ TEST_CONSTEXPR_CXX20 bool all_the_algorithms() {
176143
}
177144
(void)std::lexicographical_compare(first, last, first2, last2, Less<T>(&copies));
178145
assert(copies == 0);
179-
#if TEST_STD_VER > 17
180-
(void)std::lexicographical_compare_three_way(first, last, first2, last2, ThreeWay<T>(&copies));
181-
assert(copies == 0);
182-
#endif
183146
(void)std::lower_bound(first, last, value, Less<T>(&copies));
184147
assert(copies == 0);
185148
(void)std::make_heap(first, last, Less<T>(&copies));
186149
assert(copies == 0);
187150
(void)std::max(value, value, Less<T>(&copies));
188151
assert(copies == 0);
189-
#if TEST_STD_VER >= 11
190-
(void)std::max({value, value}, Less<T>(&copies));
191-
assert(copies == 0);
192-
#endif
193152
(void)std::max_element(first, last, Less<T>(&copies));
194153
assert(copies == 0);
195154
(void)std::merge(first, mid, mid, last, first2, Less<T>(&copies));
196155
assert(copies == 0);
197156
(void)std::min(value, value, Less<T>(&copies));
198157
assert(copies == 0);
199-
#if TEST_STD_VER >= 11
200-
(void)std::min({value, value}, Less<T>(&copies));
201-
assert(copies == 0);
202-
#endif
203158
(void)std::min_element(first, last, Less<T>(&copies));
204159
assert(copies == 0);
205160
(void)std::minmax(value, value, Less<T>(&copies));
206161
assert(copies == 0);
207-
#if TEST_STD_VER >= 11
208-
(void)std::minmax({value, value}, Less<T>(&copies));
209-
assert(copies == 0);
210-
#endif
211162
(void)std::minmax_element(first, last, Less<T>(&copies));
212163
assert(copies == 0);
213164
(void)std::mismatch(first, last, first2, Equal<T>(&copies));
214165
assert(copies == 0);
215-
#if TEST_STD_VER > 11
216-
(void)std::mismatch(first, last, first2, last2, Equal<T>(&copies));
217-
assert(copies == 0);
218-
#endif
219166
(void)std::next_permutation(first, last, Less<T>(&copies));
220167
assert(copies == 0);
221-
#if TEST_STD_VER >= 11
222-
(void)std::none_of(first, last, UnaryTrue<T>(&copies));
223-
assert(copies == 0);
224-
#endif
225168
(void)std::nth_element(first, mid, last, Less<T>(&copies));
226169
assert(copies == 0);
227170
(void)std::partial_sort(first, mid, last, Less<T>(&copies));
@@ -299,25 +242,13 @@ bool test_segmented_iterator() {
299242
assert(copies == 1);
300243
copies = 0;
301244

302-
#if TEST_STD_VER >= 20
303-
std::vector<std::vector<int>> vecs(3, std::vector<int>(10));
304-
auto v = std::views::join(vecs);
305-
(void)std::for_each(v.begin(), v.end(), UnaryVoid<int>(&copies));
306-
assert(copies == 1);
307-
copies = 0;
308-
#endif
309-
310245
return true;
311246
}
312247

313248
int main(int, char**) {
314249
all_the_algorithms<void*>();
315250
all_the_algorithms<int>();
316251
assert(test_segmented_iterator());
317-
#if TEST_STD_VER > 17
318-
static_assert(all_the_algorithms<void*>());
319-
static_assert(all_the_algorithms<int>());
320-
#endif
321252

322253
return 0;
323254
}

libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ void test() {
9999
(void) std::equal_range(it, it, 0, pred);
100100
(void) std::equal(it, it, it);
101101
(void) std::equal(it, it, it, pred);
102-
#if TEST_STD_VER > 11
103-
(void) std::equal(it, it, it, it);
104-
(void) std::equal(it, it, it, it, pred);
105-
#endif
106102
(void) std::fill_n(it, 0, 0);
107103
(void) std::fill(it, it, 0);
108104
(void) std::find_end(it, it, it, it);
@@ -112,9 +108,6 @@ void test() {
112108
(void) std::find_if_not(it, it, pred);
113109
(void) std::find_if(it, it, pred);
114110
(void) std::find(it, it, 0);
115-
#if TEST_STD_VER > 14
116-
(void) std::for_each_n(it, 0, pred);
117-
#endif
118111
(void) std::for_each(it, it, pred);
119112
(void) std::generate_n(it, 0, pred);
120113
(void) std::generate(it, it, pred);
@@ -129,20 +122,12 @@ void test() {
129122
(void) std::is_partitioned(it, it, pred);
130123
(void) std::is_permutation(it, it, it);
131124
(void) std::is_permutation(it, it, it, pred);
132-
#if TEST_STD_VER > 11
133-
(void) std::is_permutation(it, it, it, it);
134-
(void) std::is_permutation(it, it, it, it, pred);
135-
#endif
136125
(void) std::is_sorted_until(it, it);
137126
(void) std::is_sorted_until(it, it, pred);
138127
(void) std::is_sorted(it, it);
139128
(void) std::is_sorted(it, it, pred);
140129
(void) std::lexicographical_compare(it, it, it, it);
141130
(void) std::lexicographical_compare(it, it, it, it, pred);
142-
#if TEST_STD_VER > 17
143-
(void)std::lexicographical_compare_three_way(it, it, it, it);
144-
(void)std::lexicographical_compare_three_way(it, it, it, it, std::compare_three_way());
145-
#endif
146131
(void) std::lower_bound(it, it, 0);
147132
(void) std::lower_bound(it, it, 0, pred);
148133
(void) std::make_heap(it, it);
@@ -189,14 +174,8 @@ void test() {
189174
(void) std::reverse(it, it);
190175
(void) std::rotate_copy(it, it, it, it);
191176
(void) std::rotate(it, it, it);
192-
#if TEST_STD_VER > 14
193-
(void) std::sample(it, it, it, 0, rng);
194-
#endif
195177
(void) std::search(it, it, it, it);
196178
(void) std::search(it, it, it, it, pred);
197-
#if TEST_STD_VER > 14
198-
(void) std::search(it, it, std::default_searcher<Cpp20HostileIterator<int*>>(it, it));
199-
#endif
200179
(void) std::set_difference(it, it, it, it, it);
201180
(void) std::set_difference(it, it, it, it, it, pred);
202181
(void) std::set_intersection(it, it, it, it, it);
@@ -205,10 +184,6 @@ void test() {
205184
(void) std::set_symmetric_difference(it, it, it, it, it, pred);
206185
(void) std::set_union(it, it, it, it, it);
207186
(void) std::set_union(it, it, it, it, it, pred);
208-
#if TEST_STD_VER > 17
209-
(void) std::shift_left(it, it, 0);
210-
(void) std::shift_right(it, it, 0);
211-
#endif
212187
(void) std::shuffle(it, it, rng);
213188
(void) std::sort_heap(it, it);
214189
(void) std::sort_heap(it, it, pred);

libcxx/test/libcxx-03/containers/sequences/vector/asan.pass.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,6 @@ extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
2626
void do_exit() { exit(0); }
2727

2828
int main(int, char**) {
29-
#if TEST_STD_VER >= 11
30-
{
31-
typedef int T;
32-
typedef cpp17_input_iterator<T*> MyInputIter;
33-
std::vector<T, min_allocator<T>> v;
34-
v.reserve(1);
35-
int i[] = {42};
36-
v.insert(v.begin(), MyInputIter(i), MyInputIter(i + 1));
37-
assert(v[0] == 42);
38-
assert(is_contiguous_container_asan_correct(v));
39-
}
40-
{
41-
typedef char T;
42-
typedef cpp17_input_iterator<T*> MyInputIter;
43-
std::vector<T, unaligned_allocator<T>> v;
44-
v.reserve(1);
45-
char i[] = {'a', 'b'};
46-
v.insert(v.begin(), MyInputIter(i), MyInputIter(i + 2));
47-
assert(v[0] == 'a');
48-
assert(v[1] == 'b');
49-
assert(is_contiguous_container_asan_correct(v));
50-
}
51-
#endif // TEST_STD_VER >= 11
5229
{
5330
typedef cpp17_input_iterator<int*> MyInputIter;
5431
// Sould not trigger ASan.

libcxx/test/libcxx-03/containers/sequences/vector/asan_throw.pass.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,6 @@ void test_push_back() {
6868
assert(is_contiguous_container_asan_correct(v));
6969
}
7070

71-
void test_emplace_back() {
72-
#if TEST_STD_VER >= 11
73-
std::vector<X> v;
74-
v.reserve(2);
75-
v.push_back(X(2));
76-
assert(v.size() == 1);
77-
try {
78-
v.emplace_back(42);
79-
assert(0);
80-
} catch (int e) {
81-
assert(v.size() == 1);
82-
}
83-
assert(v.size() == 1);
84-
assert(is_contiguous_container_asan_correct(v));
85-
#endif
86-
}
87-
8871
void test_insert_range() {
8972
std::vector<X> v;
9073
v.reserve(4);
@@ -119,24 +102,6 @@ void test_insert() {
119102
assert(is_contiguous_container_asan_correct(v));
120103
}
121104

122-
void test_emplace() {
123-
#if TEST_STD_VER >= 11
124-
std::vector<X> v;
125-
v.reserve(3);
126-
v.insert(v.end(), X(1));
127-
v.insert(v.begin(), X(2));
128-
assert(v.size() == 2);
129-
try {
130-
v.emplace(v.end(), 42);
131-
assert(0);
132-
} catch (int e) {
133-
assert(v.size() == 2);
134-
}
135-
assert(v.size() == 2);
136-
assert(is_contiguous_container_asan_correct(v));
137-
#endif
138-
}
139-
140105
void test_insert_range2() {
141106
std::vector<X> v;
142107
v.reserve(4);
@@ -219,10 +184,8 @@ void test_resize_param() {
219184

220185
int main(int, char**) {
221186
test_push_back();
222-
test_emplace_back();
223187
test_insert_range();
224188
test_insert();
225-
test_emplace();
226189
test_insert_range2();
227190
test_insert_n();
228191
test_insert_n2();

libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/construct.cxx20.pass.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,6 @@ struct A {
3838

3939
int move_only_constructed = 0;
4040

41-
#if TEST_STD_VER >= 11
42-
class move_only {
43-
move_only(const move_only&) = delete;
44-
move_only& operator=(const move_only&) = delete;
45-
46-
public:
47-
move_only(move_only&&) { ++move_only_constructed; }
48-
move_only& operator=(move_only&&) { return *this; }
49-
50-
move_only() { ++move_only_constructed; }
51-
~move_only() { --move_only_constructed; }
52-
53-
public:
54-
int data; // unused other than to make sizeof(move_only) == sizeof(int).
55-
// but public to suppress "-Wunused-private-field"
56-
};
57-
#endif // TEST_STD_VER >= 11
58-
5941
int main(int, char**) {
6042
globalMemCounter.reset();
6143
{
@@ -107,41 +89,6 @@ int main(int, char**) {
10789
assert(globalMemCounter.checkOutstandingNewEq(0));
10890
assert(A_constructed == 0);
10991
}
110-
#if TEST_STD_VER >= 11
111-
{
112-
std::allocator<move_only> a;
113-
assert(globalMemCounter.checkOutstandingNewEq(0));
114-
assert(move_only_constructed == 0);
115-
116-
globalMemCounter.last_new_size = 0;
117-
move_only* ap = a.allocate(3);
118-
DoNotOptimize(ap);
119-
assert(globalMemCounter.checkOutstandingNewEq(1));
120-
assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
121-
assert(move_only_constructed == 0);
122-
123-
a.construct(ap);
124-
assert(globalMemCounter.checkOutstandingNewEq(1));
125-
assert(move_only_constructed == 1);
126-
127-
a.destroy(ap);
128-
assert(globalMemCounter.checkOutstandingNewEq(1));
129-
assert(move_only_constructed == 0);
130-
131-
a.construct(ap, move_only());
132-
assert(globalMemCounter.checkOutstandingNewEq(1));
133-
assert(move_only_constructed == 1);
134-
135-
a.destroy(ap);
136-
assert(globalMemCounter.checkOutstandingNewEq(1));
137-
assert(move_only_constructed == 0);
138-
139-
a.deallocate(ap, 3);
140-
DoNotOptimize(ap);
141-
assert(globalMemCounter.checkOutstandingNewEq(0));
142-
assert(move_only_constructed == 0);
143-
}
144-
#endif
14592

14693
return 0;
14794
}

0 commit comments

Comments
 (0)