Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / variant / variant.visit / robust_against_adl.pass.cpp
blobf4b191a24623ff6e597ea762f226782cdb2a7ea2
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 // XFAIL: availability-bad_variant_access-missing && !no-exceptions
13 // <variant>
14 // template <class Visitor, class... Variants>
15 // constexpr see below visit(Visitor&& vis, Variants&&... vars);
17 #include <variant>
19 #include "test_macros.h"
21 struct Incomplete;
22 template<class T> struct Holder { T t; };
24 constexpr bool test(bool do_it)
26 if (do_it) {
27 std::variant<Holder<Incomplete>*, int> v = nullptr;
28 std::visit([](auto){}, v);
29 std::visit([](auto) -> Holder<Incomplete>* { return nullptr; }, v);
30 #if TEST_STD_VER > 17
31 std::visit<void>([](auto){}, v);
32 std::visit<void*>([](auto) -> Holder<Incomplete>* { return nullptr; }, v);
33 #endif
35 return true;
38 int main(int, char**)
40 test(true);
41 #if TEST_STD_VER > 17
42 static_assert(test(true));
43 #endif
44 return 0;