summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
diff options
context:
space:
mode:
authorStephan T. Lavavej <stl@exchange.microsoft.com>2017-01-18 20:09:56 +0000
committerStephan T. Lavavej <stl@exchange.microsoft.com>2017-01-18 20:09:56 +0000
commit3d26ee29215b0e192245e5dabbda825afd3088be (patch)
tree1a4aa716ecd5132d3920146c472416015b8d25df /libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
parent20a00933fbf52ef4492692850326b07ebee8608e (diff)
downloadbcm5719-llvm-3d26ee29215b0e192245e5dabbda825afd3088be.tar.gz
bcm5719-llvm-3d26ee29215b0e192245e5dabbda825afd3088be.zip
[libcxx] [test] Fix MSVC warnings C4127 and C6326 about constants.
MSVC has compiler warnings C4127 "conditional expression is constant" (enabled by /W4) and C6326 "Potential comparison of a constant with another constant" (enabled by /analyze). They're potentially useful, although they're slightly annoying to library devs who know what they're doing. In the latest version of the compiler, C4127 is suppressed when the compiler sees simple tests like "if (name_of_thing)", so extracting comparison expressions into named constants is a workaround. At the same time, using std::integral_constant avoids C6326, which doesn't look at template arguments. test/std/containers/sequences/vector.bool/emplace.pass.cpp Replace 1 == 1 with true, which is the same as far as the library is concerned. Fixes D28837. llvm-svn: 292432
Diffstat (limited to 'libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp')
-rw-r--r--libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
index 2f3f9bee4bc..08a2a8c71f2 100644
--- a/libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -36,7 +36,8 @@ test()
for (int i = 0; i <= 5; ++i)
{
T t(static_cast<T>(i));
- if (sizeof(T) <= sizeof(std::size_t))
+ const bool small = std::integral_constant<bool, sizeof(T) <= sizeof(std::size_t)>::value; // avoid compiler warnings
+ if (small)
{
const std::size_t result = h(t);
LIBCPP_ASSERT(result == static_cast<size_t>(t));
OpenPOWER on IntegriCloud