summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBilly Robert O'Neal III <bion@microsoft.com>2017-05-08 21:54:53 +0000
committerBilly Robert O'Neal III <bion@microsoft.com>2017-05-08 21:54:53 +0000
commit362ea7329fc8bd5a7080a78d606066024ac40b11 (patch)
tree2e5945c9eb45ea89ae39e1f5d034324ebc274ab1
parent8c401179a33273d9e606a648881885564298b989 (diff)
downloadbcm5719-llvm-362ea7329fc8bd5a7080a78d606066024ac40b11.tar.gz
bcm5719-llvm-362ea7329fc8bd5a7080a78d606066024ac40b11.zip
Fix possible loss of data warnings on amd64
In T_size_size.pass, there is an explicit template argument to std::min to ask for unsigned, to avoid type deduction errors. However, C1XX' warnings still hate this use, because a 64 bit value (a size_t) is being passed to a function accepting an unsigned (a 32 bit value). Instead, change the tests to pass around std::size_t instances, and explicitly narrow when constructing the string type under test. This also allows removal of explicit template arguments to std::min. llvm-svn: 302473
-rw-r--r--libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
index c8d14a1d0dd..67ac43494a6 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -27,16 +27,17 @@
template <class S, class SV>
void
-test(SV sv, unsigned pos, unsigned n)
+test(SV sv, std::size_t pos, std::size_t n)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
+ typedef typename S::size_type Size;
if (pos <= sv.size())
{
- S s2(sv, pos, n);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n));
LIBCPP_ASSERT(s2.__invariants());
assert(pos <= sv.size());
- unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
+ std::size_t rlen = std::min(sv.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
assert(s2.get_allocator() == A());
@@ -47,7 +48,7 @@ test(SV sv, unsigned pos, unsigned n)
{
try
{
- S s2(sv, pos, n);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n));
assert(false);
}
catch (std::out_of_range&)
@@ -60,15 +61,16 @@ test(SV sv, unsigned pos, unsigned n)
template <class S, class SV>
void
-test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
+test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& a)
{
typedef typename S::traits_type T;
+ typedef typename S::size_type Size;
if (pos <= sv.size())
{
- S s2(sv, pos, n, a);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n), a);
LIBCPP_ASSERT(s2.__invariants());
assert(pos <= sv.size());
- unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
+ std::size_t rlen = std::min(sv.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
assert(s2.get_allocator() == a);
@@ -79,7 +81,7 @@ test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
{
try
{
- S s2(sv, pos, n, a);
+ S s2(sv, static_cast<Size>(pos), static_cast<Size>(n), a);
assert(false);
}
catch (std::out_of_range&)
OpenPOWER on IntegriCloud