1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // UNSUPPORTED: libcpp-has-no-threads
10 
11 // <atomic>
12 
13 // struct atomic_flag
14 
15 // atomic_flag() = default;
16 
17 #include <atomic>
18 #include <new>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 
23 int main(int, char**)
24 {
25     std::atomic_flag f;
26     f.clear();
27     assert(f.test_and_set() == 0);
28     {
29         typedef std::atomic_flag A;
30         TEST_ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};
31         A& zero = *new (storage) A();
32         assert(!zero.test_and_set());
33         zero.~A();
34     }
35 
36   return 0;
37 }
38