1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 #include <type_traits>
16 #include "test_macros.h"
18 template <class T
, unsigned A
>
19 void test_alignment_of()
21 const unsigned AlignofResult
= TEST_ALIGNOF(T
);
22 static_assert( AlignofResult
== A
, "Golden value does not match result of alignof keyword");
23 static_assert( std::alignment_of
<T
>::value
== AlignofResult
, "");
24 static_assert( std::alignment_of
<T
>::value
== A
, "");
25 static_assert( std::alignment_of
<const T
>::value
== A
, "");
26 static_assert( std::alignment_of
<volatile T
>::value
== A
, "");
27 static_assert( std::alignment_of
<const volatile T
>::value
== A
, "");
29 static_assert( std::alignment_of_v
<T
> == A
, "");
30 static_assert( std::alignment_of_v
<const T
> == A
, "");
31 static_assert( std::alignment_of_v
<volatile T
> == A
, "");
32 static_assert( std::alignment_of_v
<const volatile T
> == A
, "");
44 test_alignment_of
<int&, 4>();
45 test_alignment_of
<Class
, 1>();
46 test_alignment_of
<int*, sizeof(std::intptr_t)>();
47 test_alignment_of
<const int*, sizeof(std::intptr_t)>();
48 test_alignment_of
<char[3], 1>();
49 test_alignment_of
<int, 4>();
50 test_alignment_of
<double, TEST_ALIGNOF(double)>();
51 test_alignment_of
<bool, 1>();
52 test_alignment_of
<unsigned, 4>();