[libcxx] [test] Replace non-Standard "atomic_flag f(false);" with Standard "atomic_fl...
authorEric Fiselier <eric@efcs.ca>
Tue, 3 May 2016 02:12:26 +0000 (02:12 +0000)
committerEric Fiselier <eric@efcs.ca>
Tue, 3 May 2016 02:12:26 +0000 (02:12 +0000)
Summary:
Replace non-Standard "atomic_flag f(false);" with Standard "atomic_flag f;" in clear tests.
Although the  value of 'f' is unspecified it shouldn't matter because these tests always call `f.test_and_set()` without checking the result, so the initial state shouldn't matter.

The test init03.pass.cpp is explicitly testing this non-Standard extension; It has been moved into the `test/libcxx` directory.

Reviewers: mclow.lists, STL_MSFT

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19758

llvm-svn: 268355

libcxx/include/atomic
libcxx/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp [moved from libcxx/test/std/atomics/atomics.flag/init03.pass.cpp with 75% similarity]
libcxx/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
libcxx/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
libcxx/test/std/atomics/atomics.flag/clear.pass.cpp

index dc117e9..a0245eb 100644 (file)
@@ -1689,7 +1689,7 @@ typedef struct atomic_flag
 #endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
     _LIBCPP_INLINE_VISIBILITY
-    atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
+    atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
 
 #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
     atomic_flag(const atomic_flag&) = delete;
 
 int main()
 {
-    std::atomic_flag f(false);
-    assert(f.test_and_set() == 0);
+    {
+        std::atomic_flag f(false);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        std::atomic_flag f(true);
+        assert(f.test_and_set() == 1);
+    }
 }
index 3a74e13..64093d6 100644 (file)
 int main()
 {
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear(&f);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear(&f);
         assert(f.test_and_set() == 0);
index 0467384..e1a9349 100644 (file)
 int main()
 {
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);
index ea5ae45..65051af 100644 (file)
 int main()
 {
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         f.clear();
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         f.clear(std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         f.clear(std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        std::atomic_flag f(false);
+        std::atomic_flag f;
         f.test_and_set();
         f.clear(std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         f.clear();
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         f.clear(std::memory_order_relaxed);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         f.clear(std::memory_order_release);
         assert(f.test_and_set() == 0);
     }
     {
-        volatile std::atomic_flag f(false);
+        volatile std::atomic_flag f;
         f.test_and_set();
         f.clear(std::memory_order_seq_cst);
         assert(f.test_and_set() == 0);