1 | // |
2 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
3 | // See https://llvm.org/LICENSE.txt for license information. |
4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
5 | // |
6 | //===----------------------------------------------------------------------===// |
7 | |
8 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
9 | |
10 | // static constexpr size_t required_alignment; |
11 | |
12 | #include <atomic> |
13 | #include <cassert> |
14 | #include <concepts> |
15 | #include <cstddef> |
16 | |
17 | template <typename T> |
18 | constexpr void check_required_alignment() { |
19 | std::same_as<const std::size_t> decltype(auto) required_alignment = std::atomic_ref<T>::required_alignment; |
20 | assert(required_alignment >= alignof(T)); |
21 | } |
22 | |
23 | constexpr bool test() { |
24 | check_required_alignment<int>(); |
25 | check_required_alignment<float>(); |
26 | check_required_alignment<int*>(); |
27 | struct Empty {}; |
28 | check_required_alignment<Empty>(); |
29 | struct Trivial { |
30 | int a; |
31 | }; |
32 | check_required_alignment<Trivial>(); |
33 | return true; |
34 | } |
35 | |
36 | int main(int, char**) { |
37 | test(); |
38 | static_assert(test()); |
39 | return 0; |
40 | } |
41 | |