blob: 11c08f50266a722559d21b04ea1fd81a0200fe05 [file] [log] [blame]
Howard Hinnant748a5272010-09-30 21:05:29 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant748a5272010-09-30 21:05:29 +00007//
8//===----------------------------------------------------------------------===//
Jonathan Roelofsb3fcc672014-09-05 19:45:05 +00009//
10// UNSUPPORTED: libcpp-has-no-threads
Howard Hinnant748a5272010-09-30 21:05:29 +000011
12// <atomic>
13
14// struct atomic_flag
15
16// atomic_flag() = default;
17
18#include <atomic>
Howard Hinnantda9ca0b2013-05-02 20:18:43 +000019#include <new>
Howard Hinnant748a5272010-09-30 21:05:29 +000020#include <cassert>
21
22int main()
23{
24 std::atomic_flag f;
Eric Fiselierb67e6892015-07-18 21:40:37 +000025 f.clear();
26 assert(f.test_and_set() == 0);
Howard Hinnantda9ca0b2013-05-02 20:18:43 +000027 {
28 typedef std::atomic_flag A;
29 _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};
30 A& zero = *new (storage) A();
31 assert(!zero.test_and_set());
32 zero.~A();
33 }
Howard Hinnant748a5272010-09-30 21:05:29 +000034}