Index: libcxx/include/system_error =================================================================== --- libcxx/include/system_error +++ libcxx/include/system_error @@ -256,6 +256,17 @@ _LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT; _LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT; +namespace __lwg3629 +{ +#ifdef _LIBCPP_CXX03_LANG + void make_error_condition(); + void make_error_code(); +#else + void make_error_condition() = delete; + void make_error_code() = delete; +#endif +} // namespace __lwg3629 + class _LIBCPP_TYPE_VIS error_condition { int __val_; @@ -273,7 +284,10 @@ error_condition(_Ep __e, typename enable_if::value>::type* = nullptr ) _NOEXCEPT - {*this = make_error_condition(__e);} + { + using __lwg3629::make_error_condition; + *this = make_error_condition(__e); + } _LIBCPP_INLINE_VISIBILITY void assign(int __val, const error_category& __cat) _NOEXCEPT @@ -290,7 +304,11 @@ error_condition& >::type operator=(_Ep __e) _NOEXCEPT - {*this = make_error_condition(__e); return *this;} + { + using __lwg3629::make_error_condition; + *this = make_error_condition(__e); + return *this; + } _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT @@ -336,7 +354,10 @@ error_code(_Ep __e, typename enable_if::value>::type* = nullptr ) _NOEXCEPT - {*this = make_error_code(__e);} + { + using __lwg3629::make_error_code; + *this = make_error_code(__e); + } _LIBCPP_INLINE_VISIBILITY void assign(int __val, const error_category& __cat) _NOEXCEPT @@ -353,7 +374,11 @@ error_code& >::type operator=(_Ep __e) _NOEXCEPT - {*this = make_error_code(__e); return *this;} + { + using __lwg3629::make_error_code; + *this = make_error_code(__e); + return *this; + } _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT Index: libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/lwg3629.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/lwg3629.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// template error_code(E e); + +// Regression test for https://github.com/llvm/llvm-project/issues/57614 + +int make_error_code; // It's important that this comes before + +#include +#include + +#include "test_macros.h" + +namespace user +{ + enum Err { }; + + std::error_code make_error_code(Err) + { return std::error_code(42, std::generic_category()); } +} + +namespace std +{ + template<> struct is_error_code_enum : true_type { }; +} + +int main(int, char**) +{ + { + std::error_code e( user::Err{} ); + assert(e.value() == 42); + assert(e.category() == std::generic_category()); + } + + return 0; +} Index: libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/lwg3629.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/lwg3629.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// class error_code + +// template error_code& operator=(E e); + +// Regression test for https://github.com/llvm/llvm-project/issues/57614 + +int make_error_code; // It's important that this comes before + +#include +#include + +#include "test_macros.h" + +namespace user +{ + enum Err { }; + + std::error_code make_error_code(Err) + { return std::error_code(42, std::generic_category()); } +} + +namespace std +{ + template<> struct is_error_code_enum : true_type { }; +} + +int main(int, char**) +{ + { + std::error_code e; + e = user::Err{}; + assert(e.value() == 42); + assert(e.category() == std::generic_category()); + } + + return 0; +} Index: libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/lwg3629.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/lwg3629.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// template error_condition(E e); + +// Regression test for https://github.com/llvm/llvm-project/issues/57614 + +int make_error_condition; // It's important that this comes before + +#include +#include + +#include "test_macros.h" + +namespace user +{ + enum Err { }; + + std::error_condition make_error_condition(Err) + { return std::error_condition(42, std::generic_category()); } +} + +namespace std +{ + template<> struct is_error_condition_enum : true_type { }; +} + +int main(int, char**) +{ + { + std::error_condition e( user::Err{} ); + assert(e.value() == 42); + assert(e.category() == std::generic_category()); + } + + return 0; +} Index: libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/lwg3629.pass.cpp =================================================================== --- /dev/null +++ libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/lwg3629.pass.cpp @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// class error_condition + +// template error_condition& operator=(E e); + +// Regression test for https://github.com/llvm/llvm-project/issues/57614 + +int make_error_condition; // It's important that this comes before + +#include +#include + +#include "test_macros.h" + +namespace user +{ + enum Err { }; + + std::error_condition make_error_condition(Err) + { return std::error_condition(42, std::generic_category()); } +} + +namespace std +{ + template<> struct is_error_condition_enum : true_type { }; +} + +int main(int, char**) +{ + { + std::error_condition e; + e = user::Err{}; + assert(e.value() == 42); + assert(e.category() == std::generic_category()); + } + + return 0; +}