[libcxx] r289107 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 8 13:38:14 PST 2016


Author: stl_msft
Date: Thu Dec  8 15:38:14 2016
New Revision: 289107

URL: http://llvm.org/viewvc/llvm-project?rev=289107&view=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.

Add static_cast<short> when constructing pair<Whatever, short> from (Something, int).

Fixes D27540.

Modified:
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp

Modified: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp Thu Dec  8 15:38:14 2016
@@ -37,22 +37,22 @@ int main()
         typedef std::pair<double, short> P;
         C c;
         C::const_iterator e = c.end();
-        R r = c.insert(e, P(3.5, 3));
+        R r = c.insert(e, P(3.5, static_cast<short>(3)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(c.end(), P(3.5, 4));
+        r = c.insert(c.end(), P(3.5, static_cast<short>(4)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(c.end(), P(4.5, 4));
+        r = c.insert(c.end(), P(4.5, static_cast<short>(4)));
         assert(c.size() == 2);
         assert(r->first == 4.5);
         assert(r->second == 4);
 
-        r = c.insert(c.end(), P(5.5, 4));
+        r = c.insert(c.end(), P(5.5, static_cast<short>(4)));
         assert(c.size() == 3);
         assert(r->first == 5.5);
         assert(r->second == 4);
@@ -90,22 +90,22 @@ int main()
         typedef std::pair<double, short> P;
         C c;
         C::const_iterator e = c.end();
-        R r = c.insert(e, P(3.5, 3));
+        R r = c.insert(e, P(3.5, static_cast<short>(3)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(c.end(), P(3.5, 4));
+        r = c.insert(c.end(), P(3.5, static_cast<short>(4)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(c.end(), P(4.5, 4));
+        r = c.insert(c.end(), P(4.5, static_cast<short>(4)));
         assert(c.size() == 2);
         assert(r->first == 4.5);
         assert(r->second == 4);
 
-        r = c.insert(c.end(), P(5.5, 4));
+        r = c.insert(c.end(), P(5.5, static_cast<short>(4)));
         assert(c.size() == 3);
         assert(r->first == 5.5);
         assert(r->second == 4);

Modified: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp Thu Dec  8 15:38:14 2016
@@ -32,25 +32,25 @@ int main()
         typedef std::pair<C::iterator, bool> R;
         typedef std::pair<double, short> P;
         C c;
-        R r = c.insert(P(3.5, 3));
+        R r = c.insert(P(3.5, static_cast<short>(3)));
         assert(r.second);
         assert(c.size() == 1);
         assert(r.first->first == 3.5);
         assert(r.first->second == 3);
 
-        r = c.insert(P(3.5, 4));
+        r = c.insert(P(3.5, static_cast<short>(4)));
         assert(!r.second);
         assert(c.size() == 1);
         assert(r.first->first == 3.5);
         assert(r.first->second == 3);
 
-        r = c.insert(P(4.5, 4));
+        r = c.insert(P(4.5, static_cast<short>(4)));
         assert(r.second);
         assert(c.size() == 2);
         assert(r.first->first == 4.5);
         assert(r.first->second == 4);
 
-        r = c.insert(P(5.5, 4));
+        r = c.insert(P(5.5, static_cast<short>(4)));
         assert(r.second);
         assert(c.size() == 3);
         assert(r.first->first == 5.5);
@@ -91,25 +91,25 @@ int main()
         typedef std::pair<C::iterator, bool> R;
         typedef std::pair<double, short> P;
         C c;
-        R r = c.insert(P(3.5, 3));
+        R r = c.insert(P(3.5, static_cast<short>(3)));
         assert(r.second);
         assert(c.size() == 1);
         assert(r.first->first == 3.5);
         assert(r.first->second == 3);
 
-        r = c.insert(P(3.5, 4));
+        r = c.insert(P(3.5, static_cast<short>(4)));
         assert(!r.second);
         assert(c.size() == 1);
         assert(r.first->first == 3.5);
         assert(r.first->second == 3);
 
-        r = c.insert(P(4.5, 4));
+        r = c.insert(P(4.5, static_cast<short>(4)));
         assert(r.second);
         assert(c.size() == 2);
         assert(r.first->first == 4.5);
         assert(r.first->second == 4);
 
-        r = c.insert(P(5.5, 4));
+        r = c.insert(P(5.5, static_cast<short>(4)));
         assert(r.second);
         assert(c.size() == 3);
         assert(r.first->first == 5.5);

Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp Thu Dec  8 15:38:14 2016
@@ -37,22 +37,22 @@ int main()
         typedef std::pair<double, short> P;
         C c;
         C::const_iterator e = c.end();
-        R r = c.insert(e, P(3.5, 3));
+        R r = c.insert(e, P(3.5, static_cast<short>(3)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(r, P(3.5, 4));
+        r = c.insert(r, P(3.5, static_cast<short>(4)));
         assert(c.size() == 2);
         assert(r->first == 3.5);
         assert(r->second == 4);
 
-        r = c.insert(c.end(), P(4.5, 4));
+        r = c.insert(c.end(), P(4.5, static_cast<short>(4)));
         assert(c.size() == 3);
         assert(r->first == 4.5);
         assert(r->second == 4);
 
-        r = c.insert(c.end(), P(5.5, 4));
+        r = c.insert(c.end(), P(5.5, static_cast<short>(4)));
         assert(c.size() == 4);
         assert(r->first == 5.5);
         assert(r->second == 4);
@@ -90,22 +90,22 @@ int main()
         typedef std::pair<double, short> P;
         C c;
         C::const_iterator e = c.end();
-        R r = c.insert(e, P(3.5, 3));
+        R r = c.insert(e, P(3.5, static_cast<short>(3)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(r, P(3.5, 4));
+        r = c.insert(r, P(3.5, static_cast<short>(4)));
         assert(c.size() == 2);
         assert(r->first == 3.5);
         assert(r->second == 4);
 
-        r = c.insert(c.end(), P(4.5, 4));
+        r = c.insert(c.end(), P(4.5, static_cast<short>(4)));
         assert(c.size() == 3);
         assert(r->first == 4.5);
         assert(r->second == 4);
 
-        r = c.insert(c.end(), P(5.5, 4));
+        r = c.insert(c.end(), P(5.5, static_cast<short>(4)));
         assert(c.size() == 4);
         assert(r->first == 5.5);
         assert(r->second == 4);

Modified: libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp Thu Dec  8 15:38:14 2016
@@ -32,22 +32,22 @@ int main()
         typedef C::iterator R;
         typedef std::pair<double, short> P;
         C c;
-        R r = c.insert(P(3.5, 3));
+        R r = c.insert(P(3.5, static_cast<short>(3)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(P(3.5, 4));
+        r = c.insert(P(3.5, static_cast<short>(4)));
         assert(c.size() == 2);
         assert(r->first == 3.5);
         assert(r->second == 4);
 
-        r = c.insert(P(4.5, 4));
+        r = c.insert(P(4.5, static_cast<short>(4)));
         assert(c.size() == 3);
         assert(r->first == 4.5);
         assert(r->second == 4);
 
-        r = c.insert(P(5.5, 4));
+        r = c.insert(P(5.5, static_cast<short>(4)));
         assert(c.size() == 4);
         assert(r->first == 5.5);
         assert(r->second == 4);
@@ -83,22 +83,22 @@ int main()
         typedef C::iterator R;
         typedef std::pair<double, short> P;
         C c;
-        R r = c.insert(P(3.5, 3));
+        R r = c.insert(P(3.5, static_cast<short>(3)));
         assert(c.size() == 1);
         assert(r->first == 3.5);
         assert(r->second == 3);
 
-        r = c.insert(P(3.5, 4));
+        r = c.insert(P(3.5, static_cast<short>(4)));
         assert(c.size() == 2);
         assert(r->first == 3.5);
         assert(r->second == 4);
 
-        r = c.insert(P(4.5, 4));
+        r = c.insert(P(4.5, static_cast<short>(4)));
         assert(c.size() == 3);
         assert(r->first == 4.5);
         assert(r->second == 4);
 
-        r = c.insert(P(5.5, 4));
+        r = c.insert(P(5.5, static_cast<short>(4)));
         assert(c.size() == 4);
         assert(r->first == 5.5);
         assert(r->second == 4);

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp Thu Dec  8 15:38:14 2016
@@ -24,7 +24,7 @@ int main()
 {
     {
         typedef std::pair<int, short> P;
-        const P p(3, 4);
+        const P p(3, static_cast<short>(4));
         assert(std::get<0>(p) == 3);
         assert(std::get<1>(p) == 4);
     }
@@ -32,7 +32,7 @@ int main()
 #if TEST_STD_VER > 11
     {
         typedef std::pair<int, short> P;
-        constexpr P p1(3, 4);
+        constexpr P p1(3, static_cast<short>(4));
         static_assert(std::get<0>(p1) == 3, "");
         static_assert(std::get<1>(p1) == 4, "");
     }

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp Thu Dec  8 15:38:14 2016
@@ -28,7 +28,7 @@ int main()
 {
     {
     typedef std::pair<std::unique_ptr<int>, short> P;
-    const P p(std::unique_ptr<int>(new int(3)), 4);
+    const P p(std::unique_ptr<int>(new int(3)), static_cast<short>(4));
     static_assert(std::is_same<const std::unique_ptr<int>&&, decltype(std::get<0>(std::move(p)))>::value, "");
     static_assert(noexcept(std::get<0>(std::move(p))), "");
     const std::unique_ptr<int>&& ptr = std::get<0>(std::move(p));
@@ -58,7 +58,7 @@ int main()
 #if TEST_STD_VER > 11
     {
     typedef std::pair<int, short> P;
-    constexpr const P p1(3, 4);
+    constexpr const P p1(3, static_cast<short>(4));
     static_assert(std::get<0>(std::move(p1)) == 3, "");
     static_assert(std::get<1>(std::move(p1)) == 4, "");
     }

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp Thu Dec  8 15:38:14 2016
@@ -34,7 +34,7 @@ int main()
 {
     {
         typedef std::pair<int, short> P;
-        P p(3, 4);
+        P p(3, static_cast<short>(4));
         assert(std::get<0>(p) == 3);
         assert(std::get<1>(p) == 4);
         std::get<0>(p) = 5;

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp Thu Dec  8 15:38:14 2016
@@ -25,7 +25,7 @@ int main()
 {
     {
         typedef std::pair<std::unique_ptr<int>, short> P;
-        P p(std::unique_ptr<int>(new int(3)), 4);
+        P p(std::unique_ptr<int>(new int(3)), static_cast<short>(4));
         std::unique_ptr<int> ptr = std::get<0>(std::move(p));
         assert(*ptr == 3);
     }

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp Thu Dec  8 15:38:14 2016
@@ -21,7 +21,7 @@ int main()
     {
         typedef std::pair<int, short> P1;
         typedef std::pair<double, long> P2;
-        P1 p1(3, 4);
+        P1 p1(3, static_cast<short>(4));
         P2 p2;
         p2 = p1;
         assert(p2.first == 3);

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp Thu Dec  8 15:38:14 2016
@@ -34,7 +34,7 @@ int main()
     {
         typedef std::pair<std::unique_ptr<Derived>, short> P1;
         typedef std::pair<std::unique_ptr<Base>, long> P2;
-        P1 p1(std::unique_ptr<Derived>(), 4);
+        P1 p1(std::unique_ptr<Derived>(), static_cast<short>(4));
         P2 p2;
         p2 = std::move(p1);
         assert(p2.first == nullptr);

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp Thu Dec  8 15:38:14 2016
@@ -21,7 +21,7 @@ int main()
     {
         typedef std::pair<int, short> P1;
         typedef std::pair<double, long> P2;
-        const P1 p1(3, 4);
+        const P1 p1(3, static_cast<short>(4));
         const P2 p2 = p1;
         assert(p2.first == 3);
         assert(p2.second == 4);

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp Thu Dec  8 15:38:14 2016
@@ -22,7 +22,7 @@ int main()
 {
     {
         typedef std::pair<int, short> P1;
-        P1 p1(3, 4);
+        P1 p1(3, static_cast<short>(4));
         P1 p2 = p1;
         assert(p2.first == 3);
         assert(p2.second == 4);
@@ -30,7 +30,7 @@ int main()
 #if TEST_STD_VER > 11
     {
         typedef std::pair<int, short> P1;
-        constexpr P1 p1(3, 4);
+        constexpr P1 p1(3, static_cast<short>(4));
         constexpr P1 p2 = p1;
         static_assert(p2.first == 3, "");
         static_assert(p2.second == 4, "");

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp Thu Dec  8 15:38:14 2016
@@ -31,7 +31,7 @@ int main()
     {
         typedef std::pair<int, short> P1;
         static_assert(std::is_move_constructible<P1>::value, "");
-        P1 p1(3, 4);
+        P1 p1(3, static_cast<short>(4));
         P1 p2 = std::move(p1);
         assert(p2.first == 3);
         assert(p2.second == 4);

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp Thu Dec  8 15:38:14 2016
@@ -29,8 +29,8 @@ int main()
 {
     {
         typedef std::pair<int, short> P1;
-        P1 p1(3, 4);
-        P1 p2(5, 6);
+        P1 p1(3, static_cast<short>(4));
+        P1 p2(5, static_cast<short>(6));
         p1.swap(p2);
         assert(p1.first == 5);
         assert(p1.second == 6);

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp Thu Dec  8 15:38:14 2016
@@ -27,8 +27,8 @@ int main()
 {
     {
         typedef std::pair<int, short> P;
-        P p1(3, 4);
-        P p2(3, 4);
+        P p1(3, static_cast<short>(4));
+        P p2(3, static_cast<short>(4));
         assert( (p1 == p2));
         assert(!(p1 != p2));
         assert(!(p1 <  p2));
@@ -38,8 +38,8 @@ int main()
     }
     {
         typedef std::pair<int, short> P;
-        P p1(2, 4);
-        P p2(3, 4);
+        P p1(2, static_cast<short>(4));
+        P p2(3, static_cast<short>(4));
         assert(!(p1 == p2));
         assert( (p1 != p2));
         assert( (p1 <  p2));
@@ -49,8 +49,8 @@ int main()
     }
     {
         typedef std::pair<int, short> P;
-        P p1(3, 2);
-        P p2(3, 4);
+        P p1(3, static_cast<short>(2));
+        P p2(3, static_cast<short>(4));
         assert(!(p1 == p2));
         assert( (p1 != p2));
         assert( (p1 <  p2));
@@ -60,8 +60,8 @@ int main()
     }
     {
         typedef std::pair<int, short> P;
-        P p1(3, 4);
-        P p2(2, 4);
+        P p1(3, static_cast<short>(4));
+        P p2(2, static_cast<short>(4));
         assert(!(p1 == p2));
         assert( (p1 != p2));
         assert(!(p1 <  p2));
@@ -71,8 +71,8 @@ int main()
     }
     {
         typedef std::pair<int, short> P;
-        P p1(3, 4);
-        P p2(3, 2);
+        P p1(3, static_cast<short>(4));
+        P p2(3, static_cast<short>(2));
         assert(!(p1 == p2));
         assert( (p1 != p2));
         assert(!(p1 <  p2));
@@ -84,8 +84,8 @@ int main()
 #if TEST_STD_VER > 11
     {
         typedef std::pair<int, short> P;
-        constexpr P p1(3, 4);
-        constexpr P p2(3, 2);
+        constexpr P p1(3, static_cast<short>(4));
+        constexpr P p2(3, static_cast<short>(2));
         static_assert(!(p1 == p2), "");
         static_assert( (p1 != p2), "");
         static_assert(!(p1 <  p2), "");

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp?rev=289107&r1=289106&r2=289107&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp Thu Dec  8 15:38:14 2016
@@ -20,8 +20,8 @@ int main()
 {
     {
         typedef std::pair<int, short> P1;
-        P1 p1(3, 4);
-        P1 p2(5, 6);
+        P1 p1(3, static_cast<short>(4));
+        P1 p2(5, static_cast<short>(6));
         swap(p1, p2);
         assert(p1.first == 5);
         assert(p1.second == 6);




More information about the cfe-commits mailing list