From e17ec8e9baa81d82cb1dde612b760dec72663d7b Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Fri, 2 Sep 2022 18:46:59 +0200 Subject: [libc++] Make charconv require C++17 or later. Implementing the paper P2291R3 Add Constexpr Modifiers to Functions to_chars and from_chars for Integral Types in Header Gives issues in language versions prior to C++17. As suggested in D131855 disable the code prior to C++17. This removes libc++'s extension. Reviewed By: ldionne, #libc_vendors, #libc, philnik Differential Revision: https://reviews.llvm.org/D133216 --- libcxx/docs/ReleaseNotes.rst | 6 ++++++ libcxx/include/__charconv/chars_format.h | 4 ++-- libcxx/include/__charconv/from_chars_result.h | 4 ++-- libcxx/include/__charconv/tables.h | 4 ++-- libcxx/include/__charconv/to_chars_base_10.h | 4 ++-- libcxx/include/__charconv/to_chars_result.h | 4 ++-- libcxx/include/charconv | 9 ++------- .../charconv/charconv.from.chars/integral.bool.fail.cpp | 5 ++--- .../std/utilities/charconv/charconv.from.chars/integral.pass.cpp | 4 +--- .../charconv/charconv.from.chars/integral.roundtrip.pass.cpp | 4 +--- .../std/utilities/charconv/charconv.syn/chars_format.pass.cpp | 5 +---- .../utilities/charconv/charconv.to.chars/integral.bool.fail.cpp | 5 ++--- .../std/utilities/charconv/charconv.to.chars/integral.pass.cpp | 4 +--- 13 files changed, 26 insertions(+), 36 deletions(-) (limited to 'libcxx') diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst index 8a49ec4..b010213e 100644 --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -78,6 +78,12 @@ Deprecations and Removals reach out to the libc++ developers if you find something missing in the new configuration system. +- The functions ``to_chars`` and ``from_chars`` for integral types are + available starting with C++17. Libc++ offered these functions in C++11 and + C++14 as an undocumented extension. This extension makes it hard to implement + the C++23 paper that makes these functions ``constexpr``, therefore the + extension has been removed. + Upcoming Deprecations and Removals ---------------------------------- diff --git a/libcxx/include/__charconv/chars_format.h b/libcxx/include/__charconv/chars_format.h index 8028e2e..695bd87 100644 --- a/libcxx/include/__charconv/chars_format.h +++ b/libcxx/include/__charconv/chars_format.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER > 14 enum class _LIBCPP_ENUM_VIS chars_format { @@ -70,7 +70,7 @@ operator^=(chars_format& __x, chars_format __y) { return __x; } -#endif // _LIBCPP_CXX03_LANG +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__charconv/from_chars_result.h b/libcxx/include/__charconv/from_chars_result.h index 2cc3c11..05ffe148 100644 --- a/libcxx/include/__charconv/from_chars_result.h +++ b/libcxx/include/__charconv/from_chars_result.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER > 14 struct _LIBCPP_TYPE_VIS from_chars_result { @@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS from_chars_result # endif }; -#endif // _LIBCPP_CXX03_LANG +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__charconv/tables.h b/libcxx/include/__charconv/tables.h index 83f39e6..08664d7 100644 --- a/libcxx/include/__charconv/tables.h +++ b/libcxx/include/__charconv/tables.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER > 14 namespace __itoa { @@ -173,7 +173,7 @@ const char __table<_Tp>::__digits_base_10[200] = { } // namespace __itoa -#endif // _LIBCPP_CXX03_LANG +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__charconv/to_chars_base_10.h b/libcxx/include/__charconv/to_chars_base_10.h index d25deff..0c47597 100644 --- a/libcxx/include/__charconv/to_chars_base_10.h +++ b/libcxx/include/__charconv/to_chars_base_10.h @@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER > 14 namespace __itoa { @@ -176,7 +176,7 @@ _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __ # endif } // namespace __itoa -#endif // _LIBCPP_CXX03_LANG +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__charconv/to_chars_result.h b/libcxx/include/__charconv/to_chars_result.h index b4bc6ac..2eb4098 100644 --- a/libcxx/include/__charconv/to_chars_result.h +++ b/libcxx/include/__charconv/to_chars_result.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER > 14 struct _LIBCPP_TYPE_VIS to_chars_result { @@ -30,7 +30,7 @@ struct _LIBCPP_TYPE_VIS to_chars_result # endif }; -#endif // _LIBCPP_CXX03_LANG +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/charconv b/libcxx/include/charconv index 35ac05e..8e58d96 100644 --- a/libcxx/include/charconv +++ b/libcxx/include/charconv @@ -106,7 +106,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_CXX03_LANG +#if _LIBCPP_STD_VER > 14 to_chars_result to_chars(char*, char*, bool, int = 10) = delete; from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete; @@ -776,10 +776,6 @@ from_chars(const char* __first, const char* __last, _Tp& __value, int __base) return __from_chars_integral(__first, __last, __value, __base); } -// Floating-point implementation starts here. -// Unlike the other parts of charconv this is only available in C++17 and newer. -#if _LIBCPP_STD_VER > 14 - _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result to_chars(char* __first, char* __last, float __value); @@ -807,8 +803,7 @@ to_chars_result to_chars(char* __first, char* __last, double __value, chars_form _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision); -# endif // _LIBCPP_STD_VER > 14 -#endif // _LIBCPP_CXX03_LANG +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp index d771317..5fa62a46 100644 --- a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp +++ b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: !stdlib=libc++ && c++11 -// UNSUPPORTED: !stdlib=libc++ && c++14 +// UNSUPPORTED: c++03, c++11, c++14 + // // In diff --git a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp index fd47cb4..9cd006d 100644 --- a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp +++ b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp @@ -6,9 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: !stdlib=libc++ && c++11 -// UNSUPPORTED: !stdlib=libc++ && c++14 +// UNSUPPORTED: c++03, c++11, c++14 // diff --git a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp index cd90fae..70cefa4 100644 --- a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp +++ b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp @@ -6,9 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: !stdlib=libc++ && c++11 -// UNSUPPORTED: !stdlib=libc++ && c++14 +// UNSUPPORTED: c++03, c++11, c++14 // diff --git a/libcxx/test/std/utilities/charconv/charconv.syn/chars_format.pass.cpp b/libcxx/test/std/utilities/charconv/charconv.syn/chars_format.pass.cpp index 475852f..beee526 100644 --- a/libcxx/test/std/utilities/charconv/charconv.syn/chars_format.pass.cpp +++ b/libcxx/test/std/utilities/charconv/charconv.syn/chars_format.pass.cpp @@ -6,10 +6,7 @@ // //===----------------------------------------------------------------------===// -// Note: chars_format is a C++17 feature backported to C++11. Assert isn't -// allowed in a constexpr function in C++11. To keep the code readable, C++11 -// support is untested. -// UNSUPPORTED: c++03, c++11 +// UNSUPPORTED: c++03, c++11, c++14 // diff --git a/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp b/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp index 096d979..630799b 100644 --- a/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp +++ b/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp @@ -6,9 +6,8 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: !stdlib=libc++ && c++11 -// UNSUPPORTED: !stdlib=libc++ && c++14 +// UNSUPPORTED: c++03, c++11, c++14 + // // In diff --git a/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp b/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp index 1b83307..fa6c214 100644 --- a/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp +++ b/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp @@ -6,9 +6,7 @@ // //===----------------------------------------------------------------------===// -// UNSUPPORTED: c++03 -// UNSUPPORTED: !stdlib=libc++ && c++11 -// UNSUPPORTED: !stdlib=libc++ && c++14 +// UNSUPPORTED: c++03, c++11, c++14 // ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=12712420 // ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=12712420 -- cgit v1.1