diff options
author | Mark de Wever <koraq@xs4all.nl> | 2022-09-02 18:46:59 +0200 |
---|---|---|
committer | Mark de Wever <koraq@xs4all.nl> | 2022-10-08 13:50:30 +0200 |
commit | e17ec8e9baa81d82cb1dde612b760dec72663d7b (patch) | |
tree | 5a492f2064c48f1ab7668f108e3a58a31454a287 /libcxx | |
parent | a8fbd1157debfe5872d4a34babef3aab75732aa7 (diff) | |
download | llvm-e17ec8e9baa81d82cb1dde612b760dec72663d7b.zip llvm-e17ec8e9baa81d82cb1dde612b760dec72663d7b.tar.gz llvm-e17ec8e9baa81d82cb1dde612b760dec72663d7b.tar.bz2 |
[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 <charconv> 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
Diffstat (limited to 'libcxx')
13 files changed, 26 insertions, 36 deletions
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 + // <charconv> // 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 // <charconv> 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 // <charconv> 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 // <charconv> 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 + // <charconv> // 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 |