Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.unary / meta.unary.prop / has_unique_object_representations.pass.cpp
blobce34c8e958dba465ccf17c1dc4c06fb600490eb0
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 // UNSUPPORTED: c++03, c++11, c++14
11 // type_traits
13 // has_unique_object_representations
15 #include <type_traits>
17 #include "test_macros.h"
19 template <class T>
20 void test_has_unique_object_representations()
22 static_assert( std::has_unique_object_representations<T>::value, "");
23 static_assert( std::has_unique_object_representations<const T>::value, "");
24 static_assert( std::has_unique_object_representations<volatile T>::value, "");
25 static_assert( std::has_unique_object_representations<const volatile T>::value, "");
27 static_assert( std::has_unique_object_representations_v<T>, "");
28 static_assert( std::has_unique_object_representations_v<const T>, "");
29 static_assert( std::has_unique_object_representations_v<volatile T>, "");
30 static_assert( std::has_unique_object_representations_v<const volatile T>, "");
33 template <class T>
34 void test_has_not_has_unique_object_representations()
36 static_assert(!std::has_unique_object_representations<T>::value, "");
37 static_assert(!std::has_unique_object_representations<const T>::value, "");
38 static_assert(!std::has_unique_object_representations<volatile T>::value, "");
39 static_assert(!std::has_unique_object_representations<const volatile T>::value, "");
41 static_assert(!std::has_unique_object_representations_v<T>, "");
42 static_assert(!std::has_unique_object_representations_v<const T>, "");
43 static_assert(!std::has_unique_object_representations_v<volatile T>, "");
44 static_assert(!std::has_unique_object_representations_v<const volatile T>, "");
47 class Empty
51 class NotEmpty
53 virtual ~NotEmpty();
56 union EmptyUnion {};
57 struct NonEmptyUnion {int x; unsigned y;};
59 struct bit_zero
61 int : 0;
64 class Abstract
66 virtual ~Abstract() = 0;
69 struct A
71 ~A();
72 unsigned foo;
75 struct B
77 char bar;
78 int foo;
82 int main(int, char**)
84 test_has_not_has_unique_object_representations<void>();
85 test_has_not_has_unique_object_representations<Empty>();
86 test_has_not_has_unique_object_representations<EmptyUnion>();
87 test_has_not_has_unique_object_representations<NotEmpty>();
88 test_has_not_has_unique_object_representations<bit_zero>();
89 test_has_not_has_unique_object_representations<Abstract>();
90 test_has_not_has_unique_object_representations<B>();
92 // I would expect all three of these to have unique representations.
93 // I would also expect that there are systems where they do not.
94 // test_has_not_has_unique_object_representations<int&>();
95 // test_has_not_has_unique_object_representations<int *>();
96 // test_has_not_has_unique_object_representations<double>();
99 test_has_unique_object_representations<unsigned>();
100 test_has_unique_object_representations<NonEmptyUnion>();
101 test_has_unique_object_representations<char[3]>();
102 test_has_unique_object_representations<char[]>();
105 return 0;