diff options
author | Stephan T. Lavavej <stl@exchange.microsoft.com> | 2017-01-04 00:53:31 +0000 |
---|---|---|
committer | Stephan T. Lavavej <stl@exchange.microsoft.com> | 2017-01-04 00:53:31 +0000 |
commit | 3169d4a451aef7929cc5bc399d1a089e127868a4 (patch) | |
tree | a1a3b68be329ee6cce6b18345342b4cb69fa3c94 /test/std/utilities/allocator.adaptor | |
parent | e34f9d5ef356cced5f05d9a06a7e4de9442ddfc7 (diff) | |
download | external_libcxx-3169d4a451aef7929cc5bc399d1a089e127868a4.tar.gz external_libcxx-3169d4a451aef7929cc5bc399d1a089e127868a4.tar.bz2 external_libcxx-3169d4a451aef7929cc5bc399d1a089e127868a4.zip |
[libcxx] [test] Fix recently introduced warnings emitted by MSVC.
These tests were using malloc()'s return value without checking for null,
which MSVC's /analyze rightly warns about. Asserting that the pointer is
non-null both expresses the test's intention and silences the warning.
Fixes D27785.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290921 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/utilities/allocator.adaptor')
4 files changed, 16 insertions, 0 deletions
diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp index 9effb6ede..ef3b9302c 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_const_lvalue_pair.pass.cpp @@ -42,6 +42,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); const PairIn in(x, std::move(y)); @@ -68,6 +69,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); const PairIn in(x, y); @@ -104,6 +106,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); @@ -134,6 +137,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp index 4d371f206..6f31d2642 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_piecewise.pass.cpp @@ -42,6 +42,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); A.construct(ptr, std::piecewise_construct, @@ -68,6 +69,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); A.construct(ptr, std::piecewise_construct, @@ -104,6 +106,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); @@ -134,6 +137,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp index 1d0fb5157..a761b3288 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_rvalue.pass.cpp @@ -42,6 +42,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); PairIn in(x, std::move(y)); @@ -68,6 +69,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); PairIn in(x, y); @@ -104,6 +106,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); @@ -134,6 +137,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); diff --git a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp index 840f4ecc6..de33eeb2f 100644 --- a/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp +++ b/test/std/utilities/allocator.adaptor/allocator.adaptor.members/construct_pair_values.pass.cpp @@ -41,6 +41,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); A.construct(ptr, x, std::move(y)); @@ -65,6 +66,7 @@ void test_no_inner_alloc() using SA = std::scoped_allocator_adaptor<Alloc>; static_assert(std::uses_allocator<T, CountingAllocator<T> >::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Alloc CA(P); SA A(CA); A.construct(ptr, std::move(x), y); @@ -99,6 +101,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); @@ -127,6 +130,7 @@ void test_with_inner_alloc() static_assert(!std::uses_allocator<T, Outer>::value, ""); static_assert(std::uses_allocator<T, Inner>::value, ""); Pair * ptr = (Pair*)std::malloc(sizeof(Pair)); + assert(ptr != nullptr); Outer O(POuter); Inner I(PInner); SA A(O, I); |