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 | // <system_error> |
10 | |
11 | // class error_condition |
12 | |
13 | // template <ErrorCodeEnum E> error_condition& operator=(E e); |
14 | |
15 | // Regression test for https://github.com/llvm/llvm-project/issues/57614 |
16 | |
17 | int make_error_condition; // It's important that this comes before <system_error> |
18 | |
19 | #include <system_error> |
20 | #include <cassert> |
21 | #include <type_traits> |
22 | |
23 | #include "test_macros.h" |
24 | |
25 | namespace User { |
26 | enum Err {}; |
27 | |
28 | std::error_condition make_error_condition(Err) { return std::error_condition(42, std::generic_category()); } |
29 | } |
30 | |
31 | namespace std { |
32 | template <> |
33 | struct is_error_condition_enum<User::Err> : true_type {}; |
34 | } |
35 | |
36 | int main(int, char**) { |
37 | std::error_condition e; |
38 | e = User::Err(); |
39 | assert(e.value() == 42); |
40 | assert(e.category() == std::generic_category()); |
41 | return 0; |
42 | } |
43 |