diff options
author | Louis Dionne <ldionne@apple.com> | 2019-05-30 20:46:31 +0000 |
---|---|---|
committer | Louis Dionne <ldionne@apple.com> | 2019-05-30 20:46:31 +0000 |
commit | 5c4c44310a38ff77e15585636da57a66e737570d (patch) | |
tree | 6b969b713f66bcbbb6650fae8772bc4aba63b2c4 /pstl/test/std/algorithms | |
parent | a481b01e958b19c2eb6564ab8930eae9058967f8 (diff) | |
download | bcm5719-llvm-5c4c44310a38ff77e15585636da57a66e737570d.tar.gz bcm5719-llvm-5c4c44310a38ff77e15585636da57a66e737570d.zip |
[pstl] Remove various warnings in the pstl headers and tests
- unused parameter warnings
- don't use single-letter template parameter names, like we do in libc++
- sign-comparison warnings
- unused variables in the tests
- unused local typedefs in the tests
- the use of #include_next
- field reordering in the tests
- unused lambda captures
Note that the rationale for why the static_casts to unsigned are OK is
that last - first must always be non-negative, since [first, last) is
a valid range.
llvm-svn: 362148
Diffstat (limited to 'pstl/test/std/algorithms')
7 files changed, 15 insertions, 13 deletions
diff --git a/pstl/test/std/algorithms/alg.modifying.operations/generate.pass.cpp b/pstl/test/std/algorithms/alg.modifying.operations/generate.pass.cpp index 9b423df2933..185e98c86d2 100644 --- a/pstl/test/std/algorithms/alg.modifying.operations/generate.pass.cpp +++ b/pstl/test/std/algorithms/alg.modifying.operations/generate.pass.cpp @@ -46,7 +46,8 @@ struct test_generate { Generator_count<T> g; generate(exec, first, last, g); - EXPECT_TRUE(std::count(first, last, g.default_value()) == n, "generate wrong result for generate"); + Size count = std::count(first, last, g.default_value()); + EXPECT_TRUE(count == n, "generate wrong result for generate"); std::fill(first, last, T(0)); } @@ -54,7 +55,8 @@ struct test_generate Generator_count<T> g; const auto m = n / 2; auto last = generate_n(exec, first, m, g); - EXPECT_TRUE(std::count(first, last, g.default_value()) == m && last == std::next(first, m), + Size count = std::count(first, last, g.default_value()); + EXPECT_TRUE(count == m && last == std::next(first, m), "generate_n wrong result for generate_n"); std::fill(first, last, T(0)); } diff --git a/pstl/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp b/pstl/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp index 1bccb530254..b2ae5416497 100644 --- a/pstl/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp +++ b/pstl/test/std/algorithms/alg.nonmodifying/adjacent_find.pass.cpp @@ -39,12 +39,12 @@ test_adjacent_find_by_type() { size_t counts[] = {2, 3, 500}; - for (int32_t c = 0; c < const_size(counts); ++c) + for (size_t c = 0; c < const_size(counts); ++c) { - for (int32_t e = 0; e < (counts[c] >= 64 ? 64 : (counts[c] == 2 ? 1 : 2)); ++e) + for (size_t e = 0; e < (counts[c] >= 64 ? 64 : (counts[c] == 2 ? 1 : 2)); ++e) { - Sequence<T> in(counts[c], [](int32_t v) -> T { return T(v); }); //fill 0...n + Sequence<T> in(counts[c], [](size_t v) -> T { return T(v); }); //fill 0...n in[e] = in[e + 1] = -1; //make an adjacent pair auto i = std::adjacent_find(in.cbegin(), in.cend(), std::equal_to<T>()); @@ -56,9 +56,9 @@ test_adjacent_find_by_type() } //special cases: size=0, size=1; - for (int32_t expect = 0; expect < 1; ++expect) + for (size_t expect = 0; expect < 1; ++expect) { - Sequence<T> in(expect, [](int32_t v) -> T { return T(v); }); //fill 0...n + Sequence<T> in(expect, [](size_t v) -> T { return T(v); }); //fill 0...n auto i = std::adjacent_find(in.cbegin(), in.cend(), std::equal_to<T>()); EXPECT_TRUE(i == in.cbegin() + expect, "std::adjacent_find returned wrong result"); diff --git a/pstl/test/std/algorithms/alg.nonmodifying/equal.pass.cpp b/pstl/test/std/algorithms/alg.nonmodifying/equal.pass.cpp index ea4c09ec18d..192babb29e0 100644 --- a/pstl/test/std/algorithms/alg.nonmodifying/equal.pass.cpp +++ b/pstl/test/std/algorithms/alg.nonmodifying/equal.pass.cpp @@ -20,10 +20,10 @@ using namespace TestUtils; struct UserType { + size_t key; float32_t f; float64_t d; int32_t i; - size_t key; bool operator()(UserType a, UserType b) diff --git a/pstl/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp b/pstl/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp index dfe499c3d1e..466314e643d 100644 --- a/pstl/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp +++ b/pstl/test/std/algorithms/alg.nonmodifying/find_end.pass.cpp @@ -68,8 +68,8 @@ test(const std::size_t bits) const std::size_t max_n1 = 1000; const std::size_t max_n2 = (max_n1 * 10) / 8; - Sequence<T> in(max_n1, [max_n1, bits](std::size_t k) { return T(2 * HashBits(max_n1, bits - 1) ^ 1); }); - Sequence<T> sub(max_n2, [max_n1, bits](std::size_t k) { return T(2 * HashBits(max_n1, bits - 1)); }); + Sequence<T> in(max_n1, [bits](std::size_t k) { return T(2 * HashBits(max_n1, bits - 1) ^ 1); }); + Sequence<T> sub(max_n2, [bits](std::size_t k) { return T(2 * HashBits(max_n1, bits - 1)); }); for (std::size_t n1 = 0; n1 <= max_n1; n1 = n1 <= 16 ? n1 + 1 : size_t(3.1415 * n1)) { std::size_t sub_n[] = {0, 1, 3, n1, (n1 * 10) / 8}; diff --git a/pstl/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp b/pstl/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp index 28fcb36ad80..ac8a422698c 100644 --- a/pstl/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp +++ b/pstl/test/std/algorithms/alg.nonmodifying/search_n.pass.cpp @@ -67,7 +67,7 @@ test() } for (auto r : res) { - Sequence<T> in(n1, [n1](std::size_t k) { return T(0); }); + Sequence<T> in(n1, [](std::size_t k) { return T(0); }); std::size_t i = r, isub = 0; for (; i < n1 & isub < n2; ++i, ++isub) in[i] = value; diff --git a/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp b/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp index dbe59d02adf..27e83a1129b 100644 --- a/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp +++ b/pstl/test/std/algorithms/alg.sorting/alg.set.operations/set.pass.cpp @@ -116,7 +116,7 @@ test_set(Compare compare) for (std::size_t m = 0; m < n_max; m = m <= 16 ? m + 1 : size_t(2.71828 * m)) { //prepare the input ranges - Sequence<T1> in1(n, [n](std::size_t k) { return rand() % (2 * k + 1); }); + Sequence<T1> in1(n, [](std::size_t k) { return rand() % (2 * k + 1); }); Sequence<T2> in2(m, [m](std::size_t k) { return (m % 2) * rand() + rand() % (k + 1); }); std::sort(in1.begin(), in1.end(), compare); diff --git a/pstl/test/std/algorithms/alg.sorting/sort.pass.cpp b/pstl/test/std/algorithms/alg.sorting/sort.pass.cpp index 1997ec56c8b..2cdb24fbcaa 100644 --- a/pstl/test/std/algorithms/alg.sorting/sort.pass.cpp +++ b/pstl/test/std/algorithms/alg.sorting/sort.pass.cpp @@ -83,7 +83,7 @@ class ParanoidKey index = k.index; return *this; } - ParanoidKey(int32_t index, int32_t value, OddTag) : index(index), value(value) {} + ParanoidKey(int32_t index, int32_t value, OddTag) : value(value), index(index) {} ParanoidKey(ParanoidKey&& k) : value(k.value), index(k.index) { EXPECT_TRUE(k.isConstructed(), "source for move-construction is dead"); |