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 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14 10 11 // Throwing bad_variant_access is supported starting in macosx10.13 12 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}} 13 14 // <variant> 15 16 /* 17 18 class bad_variant_access : public exception { 19 public: 20 bad_variant_access() noexcept; 21 virtual const char* what() const noexcept; 22 }; 23 24 */ 25 26 #include <cassert> 27 #include <exception> 28 #include <type_traits> 29 #include <variant> 30 31 #include "test_macros.h" 32 main(int,char **)33int main(int, char**) { 34 static_assert(std::is_base_of<std::exception, std::bad_variant_access>::value, 35 ""); 36 static_assert(noexcept(std::bad_variant_access{}), "must be noexcept"); 37 static_assert(noexcept(std::bad_variant_access{}.what()), "must be noexcept"); 38 std::bad_variant_access ex; 39 assert(ex.what()); 40 41 return 0; 42 } 43