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