aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-04-20 12:46:11 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-04-20 12:50:50 +0100
commitf1a68574b1f8d2961d3a676dbcf0cc24b6368578 (patch)
treea68040a623b4816c335a439560141b87d8ca96b9
parent96de14f46f13201abab6fa86fb6fcaf6f03d246d (diff)
downloadgcc-f1a68574b1f8d2961d3a676dbcf0cc24b6368578.zip
gcc-f1a68574b1f8d2961d3a676dbcf0cc24b6368578.tar.gz
gcc-f1a68574b1f8d2961d3a676dbcf0cc24b6368578.tar.bz2
libstdc++: Define __cpp_lib_to_chars for C++20 [PR 100146]
This defines the feature test macro when uselocale is available, because the floating-point std::from_chars support currently depends on that. Co-authored-by: Jakub Jelinek <jakub@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/100146 * include/std/charconv (__cpp_lib_to_chars): Define conditionally. * include/std/version (__cpp_lib_to_chars): Likewise.. * testsuite/20_util/from_chars/4.cc: Only check feature test macro, not _GLIBCXX_HAVE_USELOCALE. * testsuite/20_util/from_chars/5.cc: Likewise. * testsuite/20_util/from_chars/6.cc: Likewise. * testsuite/20_util/to_chars/long_double.cc: Likewise.
-rw-r--r--libstdc++-v3/include/std/charconv5
-rw-r--r--libstdc++-v3/include/std/version4
-rw-r--r--libstdc++-v3/testsuite/20_util/from_chars/4.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/from_chars/5.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/from_chars/6.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/to_chars/long_double.cc2
6 files changed, 12 insertions, 13 deletions
diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
index 851b1e5..6e407f3 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -44,8 +44,9 @@
#include <bits/error_constants.h> // for std::errc
#include <ext/numeric_traits.h>
-// FIXME: Define when floating point is supported:
-// #define __cpp_lib_to_chars 201611L
+#if _GLIBCXX_HAVE_USELOCALE
+# define __cpp_lib_to_chars 201611L
+#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index cb25148..d9f6a3c 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -161,7 +161,9 @@
#endif
#define __cpp_lib_shared_ptr_weak_type 201606
#define __cpp_lib_string_view 201803L
-// #define __cpp_lib_to_chars 201611L
+#if _GLIBCXX_HAVE_USELOCALE
+# define __cpp_lib_to_chars 201611L
+#endif
#define __cpp_lib_unordered_map_try_emplace 201411
#define __cpp_lib_variant 201606L
#endif
diff --git a/libstdc++-v3/testsuite/20_util/from_chars/4.cc b/libstdc++-v3/testsuite/20_util/from_chars/4.cc
index 1482b5d..7cee4dc 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/4.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/4.cc
@@ -28,9 +28,7 @@
// Test std::from_chars floating-point conversions.
-// As of July 2020 __cpp_lib_to_chars is not defined, but std::from_chars
-// works for floating-point types when _GLIBCXX_HAVE_USELOCALE is defined.
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
void
test01()
{
@@ -363,7 +361,7 @@ test06()
int
main()
{
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
test01();
test02();
test03();
diff --git a/libstdc++-v3/testsuite/20_util/from_chars/5.cc b/libstdc++-v3/testsuite/20_util/from_chars/5.cc
index dd5f922..fa86ab7 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/5.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/5.cc
@@ -25,9 +25,7 @@
// Test std::from_chars error handling.
-// As of July 2020 __cpp_lib_to_chars is not defined, but std::from_chars
-// works for floating-point types when _GLIBCXX_HAVE_USELOCALE is defined.
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
void
test01()
{
@@ -160,7 +158,7 @@ test04()
int
main()
{
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
test01();
test02();
test03();
diff --git a/libstdc++-v3/testsuite/20_util/from_chars/6.cc b/libstdc++-v3/testsuite/20_util/from_chars/6.cc
index 58e0f1f..139a181 100644
--- a/libstdc++-v3/testsuite/20_util/from_chars/6.cc
+++ b/libstdc++-v3/testsuite/20_util/from_chars/6.cc
@@ -27,7 +27,7 @@
void
test01()
{
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
#if _GLIBCXX_USE_C99_FENV_TR1
double d;
std::fesetround(FE_DOWNWARD);
diff --git a/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc b/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc
index 22d4206..8cf45ad 100644
--- a/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc
+++ b/libstdc++-v3/testsuite/20_util/to_chars/long_double.cc
@@ -69,7 +69,7 @@ test01()
// Verifies correctness of the hexadecimal form [BEGIN,END) for VALUE by
// round-tripping it through from_chars (if available).
auto verify_via_from_chars = [] (char *begin, char *end, long double value) {
-#if __cpp_lib_to_chars >= 201611L || _GLIBCXX_HAVE_USELOCALE
+#if __cpp_lib_to_chars >= 201611L
long double roundtrip;
auto result = from_chars(begin, end, roundtrip, chars_format::hex);
VERIFY( result.ec == errc{} );