1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // UNSUPPORTED: libcpp-has-no-threads 11 12 // <atomic> 13 14 // struct atomic_flag 15 16 // atomic_flag() = default; 17 18 #include <atomic> 19 #include <new> 20 #include <cassert> 21 22 #include "test_macros.h" 23 24 int main() 25 { 26 std::atomic_flag f; 27 f.clear(); 28 assert(f.test_and_set() == 0); 29 { 30 typedef std::atomic_flag A; 31 TEST_ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1}; 32 A& zero = *new (storage) A(); 33 assert(!zero.test_and_set()); 34 zero.~A(); 35 } 36 } 37