Fix unused variable warnings in atomic tests

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242625 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier 2015-07-18 21:40:37 +00:00
parent 7b86ce5cc4
commit 462410703d
5 changed files with 7 additions and 5 deletions

View File

@ -22,7 +22,8 @@
int main()
{
std::atomic_flag f;
f.clear();
assert(f.test_and_set() == 0);
{
typedef std::atomic_flag A;
_ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};

View File

@ -81,12 +81,13 @@ do_test()
{
typedef typename std::remove_pointer<T>::type X;
A obj(T(0));
bool b0 = obj.is_lock_free();
((void)b0); // mark as unused
assert(obj == T(0));
std::atomic_init(&obj, T(1));
assert(obj == T(1));
std::atomic_init(&obj, T(2));
assert(obj == T(2));
bool b0 = obj.is_lock_free();
obj.store(T(0));
assert(obj == T(0));
obj.store(T(1), std::memory_order_release);

View File

@ -60,7 +60,6 @@
int main()
{
{
volatile std::atomic<bool> _;
volatile std::atomic<bool> obj(true);
assert(obj == true);
std::atomic_init(&obj, false);
@ -116,7 +115,6 @@ int main()
assert(obj == true);
}
{
std::atomic<bool> _;
std::atomic<bool> obj(true);
assert(obj == true);
std::atomic_init(&obj, false);
@ -172,7 +170,6 @@ int main()
assert(obj == true);
}
{
std::atomic_bool _;
std::atomic_bool obj(true);
assert(obj == true);
std::atomic_init(&obj, false);

View File

@ -103,6 +103,7 @@ do_test()
std::atomic_init(&obj, T(2));
assert(obj == T(2));
bool b0 = obj.is_lock_free();
((void)b0); // mark as unused
obj.store(T(0));
assert(obj == T(0));
obj.store(T(1), std::memory_order_release);

View File

@ -20,6 +20,7 @@
// atomic_is_lock_free(const atomic<T>* obj);
#include <atomic>
#include <cassert>
template <class T>
void
@ -30,6 +31,7 @@ test()
bool b1 = std::atomic_is_lock_free(static_cast<const A*>(&t));
volatile A vt;
bool b2 = std::atomic_is_lock_free(static_cast<const volatile A*>(&vt));
assert(b1 == b2);
}
struct A