From c71bd55b5dd20dd94c5b87a30adb1da7e81c5114 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sun, 11 Dec 2016 05:31:00 +0000 Subject: Enable the -Wsign-compare warning to better support MSVC llvm-svn: 289363 --- .../alg.rotate/rotate.pass.cpp | 35 +++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate') diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp index b7da7354ca2..515c79761ee 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp @@ -15,10 +15,9 @@ #include #include -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include -#endif +#include "test_macros.h" #include "test_iterators.h" template @@ -26,7 +25,7 @@ void test() { int ia[] = {0}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); + const int sa = static_cast(sizeof(ia)/sizeof(ia[0])); Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia)); assert(base(r) == ia); assert(ia[0] == 0); @@ -38,7 +37,7 @@ test() assert(ia[0] == 0); int ib[] = {0, 1}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); + const int sb = static_cast(sizeof(ib)/sizeof(ib[0])); r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb)); assert(base(r) == ib+sb); assert(ib[0] == 0); @@ -53,7 +52,7 @@ test() assert(ib[1] == 0); int ic[] = {0, 1, 2}; - const unsigned sc = sizeof(ic)/sizeof(ic[0]); + const int sc = static_cast(sizeof(ic)/sizeof(ic[0])); r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc)); assert(base(r) == ic+sc); assert(ic[0] == 0); @@ -76,7 +75,7 @@ test() assert(ic[2] == 2); int id[] = {0, 1, 2, 3}; - const unsigned sd = sizeof(id)/sizeof(id[0]); + const int sd = static_cast(sizeof(id)/sizeof(id[0])); r = std::rotate(Iter(id), Iter(id), Iter(id+sd)); assert(base(r) == id+sd); assert(id[0] == 0); @@ -109,7 +108,7 @@ test() assert(id[3] == 1); int ie[] = {0, 1, 2, 3, 4}; - const unsigned se = sizeof(ie)/sizeof(ie[0]); + const int se = static_cast(sizeof(ie)/sizeof(ie[0])); r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se)); assert(base(r) == ie+se); assert(ie[0] == 0); @@ -154,7 +153,7 @@ test() assert(ie[4] == 4); int ig[] = {0, 1, 2, 3, 4, 5}; - const unsigned sg = sizeof(ig)/sizeof(ig[0]); + const int sg = static_cast(sizeof(ig)/sizeof(ig[0])); r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg)); assert(base(r) == ig+sg); assert(ig[0] == 0); @@ -213,14 +212,14 @@ test() assert(ig[5] == 2); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 template void test1() { std::unique_ptr ia[1]; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); + const int sa = static_cast(sizeof(ia)/sizeof(ia[0])); for (int i = 0; i < sa; ++i) ia[i].reset(new int(i)); Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia)); @@ -234,7 +233,7 @@ test1() assert(*ia[0] == 0); std::unique_ptr ib[2]; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); + const int sb = static_cast(sizeof(ib)/sizeof(ib[0])); for (int i = 0; i < sb; ++i) ib[i].reset(new int(i)); r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb)); @@ -251,7 +250,7 @@ test1() assert(*ib[1] == 0); std::unique_ptr ic[3]; - const unsigned sc = sizeof(ic)/sizeof(ic[0]); + const int sc = static_cast(sizeof(ic)/sizeof(ic[0])); for (int i = 0; i < sc; ++i) ic[i].reset(new int(i)); r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc)); @@ -276,7 +275,7 @@ test1() assert(*ic[2] == 2); std::unique_ptr id[4]; - const unsigned sd = sizeof(id)/sizeof(id[0]); + const int sd = static_cast(sizeof(id)/sizeof(id[0])); for (int i = 0; i < sd; ++i) id[i].reset(new int(i)); r = std::rotate(Iter(id), Iter(id), Iter(id+sd)); @@ -311,7 +310,7 @@ test1() assert(*id[3] == 1); std::unique_ptr ie[5]; - const unsigned se = sizeof(ie)/sizeof(ie[0]); + const int se = static_cast(sizeof(ie)/sizeof(ie[0])); for (int i = 0; i < se; ++i) ie[i].reset(new int(i)); r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se)); @@ -358,7 +357,7 @@ test1() assert(*ie[4] == 4); std::unique_ptr ig[6]; - const unsigned sg = sizeof(ig)/sizeof(ig[0]); + const int sg = static_cast(sizeof(ig)/sizeof(ig[0])); for (int i = 0; i < sg; ++i) ig[i].reset(new int(i)); r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg)); @@ -419,7 +418,7 @@ test1() assert(*ig[5] == 2); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif // TEST_STD_VER >= 11 int main() { @@ -428,12 +427,12 @@ int main() test >(); test(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 test1*> >(); test1*> >(); test1*> >(); test1*>(); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } -- cgit v1.2.3