EricWF retitled this revision from "[libcxx] [test] Replace non-Standard 
"atomic_flag f(false);" with Standard "atomic_flag f = ATOMIC_FLAG_INIT;"." to 
"[libcxx] [test] Replace non-Standard "atomic_flag f(false);" with Standard 
"atomic_flag f;" ".
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 55920.
EricWF added a comment.

@STL_MSFT Does this work for you? I simply removed the initializer and call the 
default constructor instead. This leaves 'f' in an unspecified state but that 
shouldn't matter because we always call 'f.test_and_set()' before testing the 
clear operation.


http://reviews.llvm.org/D19758

Files:
  include/atomic
  test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
  test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
  test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
  test/std/atomics/atomics.flag/clear.pass.cpp
  test/std/atomics/atomics.flag/init03.pass.cpp

Index: test/std/atomics/atomics.flag/init03.pass.cpp
===================================================================
--- test/std/atomics/atomics.flag/init03.pass.cpp
+++ /dev/null
@@ -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);
-}
Index: test/std/atomics/atomics.flag/clear.pass.cpp
===================================================================
--- test/std/atomics/atomics.flag/clear.pass.cpp
+++ test/std/atomics/atomics.flag/clear.pass.cpp
@@ -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);
Index: test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
===================================================================
--- test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
+++ test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
@@ -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);
Index: test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
===================================================================
--- test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
+++ test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp
@@ -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);
Index: test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
===================================================================
--- /dev/null
+++ test/libcxx/atomics/atomics.flag/init_bool.pass.cpp
@@ -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);
+    }
+}
Index: include/atomic
===================================================================
--- include/atomic
+++ include/atomic
@@ -1689,7 +1689,7 @@
 #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;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to