Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.trans / meta.trans.other / aligned_union.pass.cpp
blob73ca06532f0829c549edb603935e1629fe73ceaf
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 //===----------------------------------------------------------------------===//
9 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
11 // type_traits
13 // aligned_union<size_t Len, class ...Types>
15 // Issue 3034 added:
16 // The member typedef type shall be a trivial standard-layout type.
18 #include <type_traits>
20 #include "test_macros.h"
22 int main(int, char**)
25 typedef std::aligned_union<10, char >::type T1;
26 #if TEST_STD_VER > 11
27 ASSERT_SAME_TYPE(T1, std::aligned_union_t<10, char>);
28 #endif
29 static_assert(std::is_trivial<T1>::value, "");
30 static_assert(std::is_standard_layout<T1>::value, "");
31 static_assert(std::alignment_of<T1>::value == 1, "");
32 static_assert(sizeof(T1) == 10, "");
35 typedef std::aligned_union<10, short >::type T1;
36 #if TEST_STD_VER > 11
37 ASSERT_SAME_TYPE(T1, std::aligned_union_t<10, short>);
38 #endif
39 static_assert(std::is_trivial<T1>::value, "");
40 static_assert(std::is_standard_layout<T1>::value, "");
41 static_assert(std::alignment_of<T1>::value == 2, "");
42 static_assert(sizeof(T1) == 10, "");
45 typedef std::aligned_union<10, int >::type T1;
46 #if TEST_STD_VER > 11
47 ASSERT_SAME_TYPE(T1, std::aligned_union_t<10, int>);
48 #endif
49 static_assert(std::is_trivial<T1>::value, "");
50 static_assert(std::is_standard_layout<T1>::value, "");
51 static_assert(std::alignment_of<T1>::value == 4, "");
52 static_assert(sizeof(T1) == 12, "");
55 typedef std::aligned_union<10, double >::type T1;
56 #if TEST_STD_VER > 11
57 ASSERT_SAME_TYPE(T1, std::aligned_union_t<10, double>);
58 #endif
59 static_assert(std::is_trivial<T1>::value, "");
60 static_assert(std::is_standard_layout<T1>::value, "");
61 static_assert(std::alignment_of<T1>::value == 8, "");
62 static_assert(sizeof(T1) == 16, "");
65 typedef std::aligned_union<10, short, char >::type T1;
66 #if TEST_STD_VER > 11
67 ASSERT_SAME_TYPE(T1, std::aligned_union_t<10, short, char>);
68 #endif
69 static_assert(std::is_trivial<T1>::value, "");
70 static_assert(std::is_standard_layout<T1>::value, "");
71 static_assert(std::alignment_of<T1>::value == 2, "");
72 static_assert(sizeof(T1) == 10, "");
75 typedef std::aligned_union<10, char, short >::type T1;
76 #if TEST_STD_VER > 11
77 ASSERT_SAME_TYPE(T1, std::aligned_union_t<10, char, short>);
78 #endif
79 static_assert(std::is_trivial<T1>::value, "");
80 static_assert(std::is_standard_layout<T1>::value, "");
81 static_assert(std::alignment_of<T1>::value == 2, "");
82 static_assert(sizeof(T1) == 10, "");
85 typedef std::aligned_union<2, int, char, short >::type T1;
86 #if TEST_STD_VER > 11
87 ASSERT_SAME_TYPE(T1, std::aligned_union_t<2, int, char, short>);
88 #endif
89 static_assert(std::is_trivial<T1>::value, "");
90 static_assert(std::is_standard_layout<T1>::value, "");
91 static_assert(std::alignment_of<T1>::value == 4, "");
92 static_assert(sizeof(T1) == 4, "");
95 typedef std::aligned_union<2, char, int, short >::type T1;
96 #if TEST_STD_VER > 11
97 ASSERT_SAME_TYPE(T1, std::aligned_union_t<2, char, int, short>);
98 #endif
99 static_assert(std::is_trivial<T1>::value, "");
100 static_assert(std::is_standard_layout<T1>::value, "");
101 static_assert(std::alignment_of<T1>::value == 4, "");
102 static_assert(sizeof(T1) == 4, "");
105 typedef std::aligned_union<2, char, short, int >::type T1;
106 #if TEST_STD_VER > 11
107 ASSERT_SAME_TYPE(T1, std::aligned_union_t<2, char, short, int>);
108 #endif
109 static_assert(std::is_trivial<T1>::value, "");
110 static_assert(std::is_standard_layout<T1>::value, "");
111 static_assert(std::alignment_of<T1>::value == 4, "");
112 static_assert(sizeof(T1) == 4, "");
115 return 0;