[libcxx] r268355 - [libcxx] [test] Replace non-Standard "atomic_flag f(false); " with Standard "atomic_flag f; "

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Mon May 2 19:12:26 PDT 2016


Author: ericwf
Date: Mon May  2 21:12:26 2016
New Revision: 268355

URL: http://llvm.org/viewvc/llvm-project?rev=268355&view=rev
Log:
[libcxx] [test] Replace non-Standard "atomic_flag f(false);" with Standard "atomic_flag f;" 

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

Added:
    libcxx/trunk/test/libcxx/atomics/atomics.flag/
    libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
Removed:
    libcxx/trunk/test/std/atomics/atomics.flag/init03.pass.cpp
Modified:
    libcxx/trunk/include/atomic
    libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
    libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
    libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp

Modified: libcxx/trunk/include/atomic
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=268355&r1=268354&r2=268355&view=diff
==============================================================================
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Mon May  2 21:12:26 2016
@@ -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;

Added: libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp?rev=268355&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/atomics/atomics.flag/init_bool.pass.cpp Mon May  2 21:12:26 2016
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// <atomic>
+
+// struct atomic_flag
+
+// TESTING EXTENSION atomic_flag(bool)
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    {
+        std::atomic_flag f(false);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        std::atomic_flag f(true);
+        assert(f.test_and_set() == 1);
+    }
+}

Modified: libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp?rev=268355&r1=268354&r2=268355&view=diff
==============================================================================
--- libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp (original)
+++ libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp Mon May  2 21:12:26 2016
@@ -22,13 +22,13 @@
 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);

Modified: libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp?rev=268355&r1=268354&r2=268355&view=diff
==============================================================================
--- libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp (original)
+++ libcxx/trunk/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp Mon May  2 21:12:26 2016
@@ -22,37 +22,37 @@
 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);

Modified: libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp?rev=268355&r1=268354&r2=268355&view=diff
==============================================================================
--- libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp (original)
+++ libcxx/trunk/test/std/atomics/atomics.flag/clear.pass.cpp Mon May  2 21:12:26 2016
@@ -22,49 +22,49 @@
 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);

Removed: libcxx/trunk/test/std/atomics/atomics.flag/init03.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/atomics/atomics.flag/init03.pass.cpp?rev=268354&view=auto
==============================================================================
--- libcxx/trunk/test/std/atomics/atomics.flag/init03.pass.cpp (original)
+++ libcxx/trunk/test/std/atomics/atomics.flag/init03.pass.cpp (removed)
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// UNSUPPORTED: libcpp-has-no-threads
-
-// <atomic>
-
-// struct atomic_flag
-
-// TESTING EXTENSION atomic_flag(bool)
-
-#include <atomic>
-#include <cassert>
-
-int main()
-{
-    std::atomic_flag f(false);
-    assert(f.test_and_set() == 0);
-}




More information about the cfe-commits mailing list