Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / algorithms / algorithms.results / no_unique_address.compile.pass.cpp
blob8e0a81959f27c81052e12bc619925b0fa670f518
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, c++17
11 // clang-cl and cl currently don't support [[no_unique_address]]
12 // XFAIL: msvc
14 // [algorithms.results]/1
15 // Each of the class templates specified in this subclause has the template parameters,
16 // data members, and special members specified below, and has no base classes or members
17 // other than those specified.
19 #include <algorithm>
21 #include "test_macros.h"
23 struct Empty {};
24 struct Empty2 {};
26 static_assert(sizeof(std::ranges::in_fun_result<Empty, int>) == sizeof(int));
27 static_assert(sizeof(std::ranges::in_fun_result<int, Empty>) == sizeof(int));
28 static_assert(sizeof(std::ranges::in_fun_result<Empty, Empty>) == 2);
30 static_assert(sizeof(std::ranges::in_in_result<Empty, int>) == sizeof(int));
31 static_assert(sizeof(std::ranges::in_in_result<int, Empty>) == sizeof(int));
32 static_assert(sizeof(std::ranges::in_in_result<Empty, Empty>) == 2);
34 static_assert(sizeof(std::ranges::in_out_result<Empty, int>) == sizeof(int));
35 static_assert(sizeof(std::ranges::in_out_result<int, Empty>) == sizeof(int));
36 static_assert(sizeof(std::ranges::in_out_result<Empty, Empty2>) == sizeof(char));
38 static_assert(sizeof(std::ranges::in_in_out_result<Empty, int, int>) == 2 * sizeof(int));
39 static_assert(sizeof(std::ranges::in_in_out_result<int, Empty, int>) == 2 * sizeof(int));
40 static_assert(sizeof(std::ranges::in_in_out_result<int, int, Empty>) == 2 * sizeof(int));
41 static_assert(sizeof(std::ranges::in_in_out_result<char, Empty, Empty>) == 2);
42 static_assert(sizeof(std::ranges::in_in_out_result<Empty, char, Empty>) == 2);
43 static_assert(sizeof(std::ranges::in_in_out_result<Empty, Empty, char>) == 2);
44 static_assert(sizeof(std::ranges::in_in_out_result<int, Empty, Empty2>) == sizeof(int));
45 static_assert(sizeof(std::ranges::in_in_out_result<Empty, Empty, Empty>) == 3);
47 static_assert(sizeof(std::ranges::in_out_out_result<Empty, int, int>) == 2 * sizeof(int));
48 static_assert(sizeof(std::ranges::in_out_out_result<int, Empty, int>) == 2 * sizeof(int));
49 static_assert(sizeof(std::ranges::in_out_out_result<int, int, Empty>) == 2 * sizeof(int));
50 static_assert(sizeof(std::ranges::in_out_out_result<char, Empty, Empty>) == 2);
51 static_assert(sizeof(std::ranges::in_out_out_result<Empty, char, Empty>) == 2);
52 static_assert(sizeof(std::ranges::in_out_out_result<Empty, Empty, char>) == 2);
53 static_assert(sizeof(std::ranges::in_out_out_result<int, Empty, Empty2>) == sizeof(int));
54 static_assert(sizeof(std::ranges::in_out_out_result<Empty, Empty, Empty>) == 3);
56 // In min_max_result both elements have the same type, so they can't have the same address.
57 // So the only way to test that [[no_unique_address]] is used is to have it in another struct
58 struct MinMaxNoUniqueAddress {
59 int a;
60 TEST_NO_UNIQUE_ADDRESS std::ranges::min_max_result<Empty> b;
61 int c;
64 static_assert(sizeof(std::ranges::min_max_result<Empty>) == 2);
65 static_assert(sizeof(MinMaxNoUniqueAddress) == 8);
67 static_assert(sizeof(std::ranges::in_found_result<Empty>) == sizeof(bool));