diff --git a/libcxx/docs/Status/Cxx23Issues.csv b/libcxx/docs/Status/Cxx23Issues.csv index 43282f357150cf..8a2351ceebf392 100644 --- a/libcxx/docs/Status/Cxx23Issues.csv +++ b/libcxx/docs/Status/Cxx23Issues.csv @@ -295,7 +295,7 @@ "`3847 `__","``ranges::to`` can still return views","February 2023","|Complete|","17.0","|ranges|" "`3862 `__","``basic_const_iterator``'s ``common_type`` specialization is underconstrained","February 2023","","","" "`3865 `__","Sorting a range of ``pairs``","February 2023","|Complete|","17.0","|ranges|" -"`3869 `__","Deprecate ``std::errc`` constants related to UNIX STREAMS","February 2023","","","" +"`3869 `__","Deprecate ``std::errc`` constants related to UNIX STREAMS","February 2023","|Complete|","19.0","" "`3870 `__","Remove ``voidify``","February 2023","","","" "`3871 `__","Adjust note about ``terminate``","February 2023","","","" "`3872 `__","``basic_const_iterator`` should have custom ``iter_move``","February 2023","","","" diff --git a/libcxx/include/__system_error/errc.h b/libcxx/include/__system_error/errc.h index f87df86a71e15a..e9f3656b7b9c2b 100644 --- a/libcxx/include/__system_error/errc.h +++ b/libcxx/include/__system_error/errc.h @@ -58,18 +58,18 @@ enum class errc no_child_process, // ECHILD no_link, // ENOLINK no_lock_available, // ENOLCK - no_message_available, // ENODATA + no_message_available, // ENODATA // deprecated no_message, // ENOMSG no_protocol_option, // ENOPROTOOPT no_space_on_device, // ENOSPC - no_stream_resources, // ENOSR + no_stream_resources, // ENOSR // deprecated no_such_device_or_address, // ENXIO no_such_device, // ENODEV no_such_file_or_directory, // ENOENT no_such_process, // ESRCH not_a_directory, // ENOTDIR not_a_socket, // ENOTSOCK - not_a_stream, // ENOSTR + not_a_stream, // ENOSTR // deprecated not_connected, // ENOTCONN not_enough_memory, // ENOMEM not_supported, // ENOTSUP @@ -87,7 +87,7 @@ enum class errc resource_unavailable_try_again, // EAGAIN result_out_of_range, // ERANGE state_not_recoverable, // ENOTRECOVERABLE - stream_timeout, // ETIME + stream_timeout, // ETIME // deprecated text_file_busy, // ETXTBSY timed_out, // ETIMEDOUT too_many_files_open_in_system, // ENFILE @@ -107,12 +107,34 @@ enum class errc # pragma GCC system_header #endif +// The method of pushing and popping the diagnostics fails for GCC. GCC does +// not recognize the pragma's used to generate deprecated diagnostics for +// macros. So GCC does not need the pushing and popping. +// +// TODO Remove this when the deprecated constants are removed. +#if defined(_LIBCPP_COMPILER_CLANG_BASED) +# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH _LIBCPP_SUPPRESS_DEPRECATED_PUSH +# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP _LIBCPP_SUPPRESS_DEPRECATED_POP +#else +# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH +# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP +#endif + _LIBCPP_BEGIN_NAMESPACE_STD // Some error codes are not present on all platforms, so we provide equivalents // for them: // enum class errc +// +// LWG3869 deprecates the UNIX STREAMS macros and enum values. +// This makes the code clumbersome: +// - the enum value is deprecated and should show a diagnostic, +// - the macro is deprecated and should _not_ show a diagnostic in this +// context, and +// - the macro is not always available. +// This leads to the odd pushing and popping of the deprecated +// diagnostic. _LIBCPP_DECLARE_STRONG_ENUM(errc){ address_family_not_supported = EAFNOSUPPORT, address_in_use = EADDRINUSE, @@ -154,30 +176,48 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){ no_child_process = ECHILD, no_link = ENOLINK, no_lock_available = ENOLCK, + // clang-format off + no_message_available _LIBCPP_DEPRECATED = + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH #ifdef ENODATA - no_message_available = ENODATA, + ENODATA #else - no_message_available = ENOMSG, + ENOMSG #endif + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP + , + // clang-format on no_message = ENOMSG, no_protocol_option = ENOPROTOOPT, no_space_on_device = ENOSPC, + // clang-format off + no_stream_resources _LIBCPP_DEPRECATED = + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH #ifdef ENOSR - no_stream_resources = ENOSR, + ENOSR #else - no_stream_resources = ENOMEM, + ENOMEM #endif + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP + , + // clang-format on no_such_device_or_address = ENXIO, no_such_device = ENODEV, no_such_file_or_directory = ENOENT, no_such_process = ESRCH, not_a_directory = ENOTDIR, not_a_socket = ENOTSOCK, + // clang-format off + not_a_stream _LIBCPP_DEPRECATED = + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH #ifdef ENOSTR - not_a_stream = ENOSTR, + ENOSTR #else - not_a_stream = EINVAL, + EINVAL #endif + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP + , + // clang-format on not_connected = ENOTCONN, not_enough_memory = ENOMEM, not_supported = ENOTSUP, @@ -195,11 +235,17 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){ resource_unavailable_try_again = EAGAIN, result_out_of_range = ERANGE, state_not_recoverable = ENOTRECOVERABLE, + // clang-format off + stream_timeout _LIBCPP_DEPRECATED = + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH #ifdef ETIME - stream_timeout = ETIME, + ETIME #else - stream_timeout = ETIMEDOUT, + ETIMEDOUT #endif + _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP + , + // clang-format on text_file_busy = ETXTBSY, timed_out = ETIMEDOUT, too_many_files_open_in_system = ENFILE, diff --git a/libcxx/include/cerrno b/libcxx/include/cerrno index d488fa72a54b7a..6171ae31f18479 100644 --- a/libcxx/include/cerrno +++ b/libcxx/include/cerrno @@ -38,4 +38,17 @@ Macros: # pragma GCC system_header #endif +#ifdef ENODATA +# pragma clang deprecated(ENODATA, "ENODATA is deprecated in ISO C++") +#endif +#ifdef ENOSR +# pragma clang deprecated(ENOSR, "ENOSR is deprecated in ISO C++") +#endif +#ifdef ENOSTR +# pragma clang deprecated(ENOSTR, "ENOSTR is deprecated in ISO C++") +#endif +#ifdef ETIME +# pragma clang deprecated(ETIME, "ETIME is deprecated in ISO C++") +#endif + #endif // _LIBCPP_CERRNO diff --git a/libcxx/src/random.cpp b/libcxx/src/random.cpp index c7073c54da6b55..93590af310e51a 100644 --- a/libcxx/src/random.cpp +++ b/libcxx/src/random.cpp @@ -79,8 +79,10 @@ unsigned random_device::operator()() { char* p = reinterpret_cast(&r); while (n > 0) { ssize_t s = read(__f_, p, n); + _LIBCPP_SUPPRESS_DEPRECATED_PUSH if (s == 0) - __throw_system_error(ENODATA, "random_device got EOF"); + __throw_system_error(ENODATA, "random_device got EOF"); // TODO ENODATA -> ENOMSG + _LIBCPP_SUPPRESS_DEPRECATED_POP if (s == -1) { if (errno != EINTR) __throw_system_error(errno, "random_device got an unexpected error"); diff --git a/libcxx/test/std/depr.cerro/cerrno.syn.verify.cpp b/libcxx/test/std/depr.cerro/cerrno.syn.verify.cpp new file mode 100644 index 00000000000000..3a38605570dafb --- /dev/null +++ b/libcxx/test/std/depr.cerro/cerrno.syn.verify.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: clang-modules-build +// UNSUPPORTED: apple-clang && c++03 + +// + +// tests LWG 3869 deprecated macros. +// +// Note the macros may not be defined. When they are not defined the +// ifdef XXX does not trigger a deprecated message. So use them in the +// ifdef and test for 2 deprecated messages. + +#include + +#ifdef ENODATA +[[maybe_unused]] int nodata = + ENODATA; // expected-warning@cerrno.syn.verify.cpp:* 2 {{macro 'ENODATA' has been marked as deprecated}} +#endif +#ifdef ENOSR +[[maybe_unused]] int nosr = + ENOSR; // expected-warning@cerrno.syn.verify.cpp:* 2 {{macro 'ENOSR' has been marked as deprecated}} +#endif +#ifdef ENOSTR +[[maybe_unused]] int nostr = + ENOSTR; // expected-warning@cerrno.syn.verify.cpp:* 2 {{macro 'ENOSTR' has been marked as deprecated}} +#endif +#ifdef ETIME +[[maybe_unused]] int timeout = + ETIME; // expected-warning@cerrno.syn.verify.cpp:* 2 {{macro 'ETIME' has been marked as deprecated}} +#endif diff --git a/libcxx/test/std/depr.cerro/system.error.syn.verify.cpp b/libcxx/test/std/depr.cerro/system.error.syn.verify.cpp new file mode 100644 index 00000000000000..fab5dd5b559350 --- /dev/null +++ b/libcxx/test/std/depr.cerro/system.error.syn.verify.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// These macros do not seem to behave as expected on all Apple platforms. +// Since the macros are not provided newer POSIX versions it is expected the +// macros will be retroactively removed from C++. (The deprecation was +// retroactively.) +// UNSUPPORTED: apple-clang && (c++03 || clang-modules-build) + +// + +// enum errc {...} + +// tests LWG 3869 deprecated enum members. + +#include + +[[maybe_unused]] std::errc nodata = + std::errc::no_message_available; // expected-warning {{'no_message_available' is deprecated}} +[[maybe_unused]] std::errc nosr = + std::errc::no_stream_resources; // expected-warning {{'no_stream_resources' is deprecated}} +[[maybe_unused]] std::errc nostr = std::errc::not_a_stream; // expected-warning {{'not_a_stream' is deprecated}} +[[maybe_unused]] std::errc timeout = std::errc::stream_timeout; // expected-warning {{'stream_timeout' is deprecated}} diff --git a/libcxx/test/std/diagnostics/syserr/errc.pass.cpp b/libcxx/test/std/diagnostics/syserr/errc.pass.cpp index e44cb50102e3e1..4abee08ddc6629 100644 --- a/libcxx/test/std/diagnostics/syserr/errc.pass.cpp +++ b/libcxx/test/std/diagnostics/syserr/errc.pass.cpp @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + // // enum errc {...}