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: c++03, c++11 |
10 | // REQUIRES: availability-synchronization_library-missing |
11 | |
12 | // Test the availability markup on the C++20 Synchronization Library |
13 | // additions to <atomic>. |
14 | |
15 | #include <atomic> |
16 | |
17 | void f() { |
18 | { |
19 | std::atomic<int> i(3); |
20 | std::memory_order m = std::memory_order_relaxed; |
21 | |
22 | i.wait(4); // expected-error {{is unavailable}} |
23 | i.wait(4, m); // expected-error {{is unavailable}} |
24 | i.notify_one(); // expected-error {{is unavailable}} |
25 | i.notify_all(); // expected-error {{is unavailable}} |
26 | |
27 | std::atomic_wait(a: &i, i: 4); // expected-error {{is unavailable}} |
28 | std::atomic_wait_explicit(a: &i, i: 4, m: m); // expected-error {{is unavailable}} |
29 | std::atomic_notify_one(&i); // expected-error {{is unavailable}} |
30 | std::atomic_notify_all(&i); // expected-error {{is unavailable}} |
31 | } |
32 | |
33 | { |
34 | std::atomic<int> volatile i(3); |
35 | std::memory_order m = std::memory_order_relaxed; |
36 | |
37 | i.wait(4); // expected-error {{is unavailable}} |
38 | i.wait(4, m); // expected-error {{is unavailable}} |
39 | i.notify_one(); // expected-error {{is unavailable}} |
40 | i.notify_all(); // expected-error {{is unavailable}} |
41 | |
42 | std::atomic_wait(&i, 4); // expected-error {{is unavailable}} |
43 | std::atomic_wait_explicit(&i, 4, m); // expected-error {{is unavailable}} |
44 | std::atomic_notify_one(&i); // expected-error {{is unavailable}} |
45 | std::atomic_notify_all(&i); // expected-error {{is unavailable}} |
46 | } |
47 | |
48 | { |
49 | std::atomic_flag flag; |
50 | bool b = false; |
51 | std::memory_order m = std::memory_order_relaxed; |
52 | flag.wait(b); // expected-error {{is unavailable}} |
53 | flag.wait(b, m); // expected-error {{is unavailable}} |
54 | flag.notify_one(); // expected-error {{is unavailable}} |
55 | flag.notify_all(); // expected-error {{is unavailable}} |
56 | |
57 | std::atomic_flag_wait(&flag, b); // expected-error {{is unavailable}} |
58 | std::atomic_flag_wait_explicit(&flag, b, m); // expected-error {{is unavailable}} |
59 | std::atomic_flag_notify_one(&flag); // expected-error {{is unavailable}} |
60 | std::atomic_flag_notify_all(&flag); // expected-error {{is unavailable}} |
61 | } |
62 | |
63 | { |
64 | std::atomic_flag volatile flag; |
65 | bool b = false; |
66 | std::memory_order m = std::memory_order_relaxed; |
67 | flag.wait(b); // expected-error {{is unavailable}} |
68 | flag.wait(b, m); // expected-error {{is unavailable}} |
69 | flag.notify_one(); // expected-error {{is unavailable}} |
70 | flag.notify_all(); // expected-error {{is unavailable}} |
71 | |
72 | std::atomic_flag_wait(&flag, b); // expected-error {{is unavailable}} |
73 | std::atomic_flag_wait_explicit(&flag, b, m); // expected-error {{is unavailable}} |
74 | std::atomic_flag_notify_one(&flag); // expected-error {{is unavailable}} |
75 | std::atomic_flag_notify_all(&flag); // expected-error {{is unavailable}} |
76 | } |
77 | } |
78 | |