summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-03-22 21:28:09 +0000
committerEric Fiselier <eric@efcs.ca>2018-03-22 21:28:09 +0000
commit107d6d684539a034c6ab3a1ae915179c5bbde8ba (patch)
tree1f7689bd71145d5448f9917ba8ca589ec742efde /libcxx/test/std/utilities
parent29a21bab087dbb2c8c7e815f4816c4d5356361f9 (diff)
downloadbcm5719-llvm-107d6d684539a034c6ab3a1ae915179c5bbde8ba.tar.gz
bcm5719-llvm-107d6d684539a034c6ab3a1ae915179c5bbde8ba.zip
Use DoNotOptimize to prevent new/delete elision.
The new/delete tests, in particular those which test replacement functions, often fail when the optimizer is enabled because the calls to new/delete may be optimized away, regardless of their side-effects. This patch converts the tests to use DoNotOptimize in order to prevent the elision. llvm-svn: 328245
Diffstat (limited to 'libcxx/test/std/utilities')
-rw-r--r--libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
index 930da0b79b8..70c5e46965a 100644
--- a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
+++ b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
@@ -14,6 +14,7 @@
#include <memory>
#include <cassert>
+#include <iostream>
#include "test_macros.h"
#include "count_new.hpp"
@@ -59,7 +60,8 @@ void test_aligned() {
assert(T::constructed == 0);
globalMemCounter.last_new_size = 0;
globalMemCounter.last_new_align = 0;
- T* volatile ap = a.allocate(3);
+ T* ap = a.allocate(3);
+ DoNotOptimize(ap);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(globalMemCounter.checkNewCalledEq(1));
assert(globalMemCounter.checkAlignedNewCalledEq(ExpectAligned));
@@ -79,6 +81,7 @@ void test_aligned() {
globalMemCounter.last_new_size = 0;
globalMemCounter.last_new_align = 0;
T* volatile ap2 = a.allocate(11, (const void*)5);
+ DoNotOptimize(ap2);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(globalMemCounter.checkNewCalledEq(1));
assert(globalMemCounter.checkAlignedNewCalledEq(ExpectAligned));
@@ -87,6 +90,7 @@ void test_aligned() {
assert(T::constructed == 0);
globalMemCounter.last_delete_align = 0;
a.deallocate(ap2, 11);
+ DoNotOptimize(ap2);
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(globalMemCounter.checkDeleteCalledEq(1));
assert(globalMemCounter.checkAlignedDeleteCalledEq(ExpectAligned));
OpenPOWER on IntegriCloud