Fix test failures caused by new/delete calls getting optimized away
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@296813 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
index ff55ec7..3925f2f 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_calls_unsized_delete_array.pass.cpp
@@ -46,9 +46,11 @@
// selected.
struct A { ~A() {} };
+A *volatile x;
+
int main()
{
- A* x = new A[3];
+ x = new A[3];
assert(0 == delete_called);
assert(0 == delete_nothrow_called);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
index ad15b49..ea6c936 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
@@ -43,9 +43,11 @@
~A() {A_constructed = false;}
};
+A *volatile ap;
+
int main()
{
- A* ap = new A;
+ ap = new A;
assert(ap);
assert(A_constructed);
assert(new_called);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
index 7369c36..57fb1eb 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete11.pass.cpp
@@ -44,9 +44,11 @@
std::free(p);
}
+int *volatile x;
+
int main()
{
- int *x = new int(42);
+ x = new int(42);
assert(0 == unsized_delete_called);
assert(0 == unsized_delete_nothrow_called);
assert(0 == sized_delete_called);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
index 6c91f5c..b85b670 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp
@@ -49,9 +49,11 @@
std::free(p);
}
+int *volatile x;
+
int main()
{
- int *x = new int(42);
+ x = new int(42);
assert(0 == unsized_delete_called);
assert(0 == unsized_delete_nothrow_called);
assert(0 == sized_delete_called);
diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
index 1b6de23..61fca5f 100644
--- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
+++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
@@ -17,7 +17,7 @@
// NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation.
// REQUIRES: fsized-deallocation
-// RUN: %build -fsized-deallocation
+// RUN: %build -fsized-deallocation -O3
// RUN: %run
#if !defined(__cpp_sized_deallocation)