]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Define __cpp_lib_to_chars for C++20 [PR 100146]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 20 Apr 2021 11:46:11 +0000 (12:46 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 20 Apr 2021 11:50:50 +0000 (12:50 +0100)
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.

libstdc++-v3/include/std/charconv
libstdc++-v3/include/std/version
libstdc++-v3/testsuite/20_util/from_chars/4.cc
libstdc++-v3/testsuite/20_util/from_chars/5.cc
libstdc++-v3/testsuite/20_util/from_chars/6.cc
libstdc++-v3/testsuite/20_util/to_chars/long_double.cc

index 851b1e5cac2b572ada7b744dbc08d2ee864d7baf..6e407f31e30b0e4f5a4affb602c2f3b6ecebfd44 100644 (file)
@@ -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)
 {
index cb25148fca5ff9473255f8a8c64be20a8b8c1232..d9f6a3c3dfd38d6e49b1a66c8e5e83ac836a95dc 100644 (file)
 #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
index 1482b5dfb6ed17cd395c348e6cd4735969b6d739..7cee4dcbc2320a6e0aee95d9240df80109812c9b 100644 (file)
@@ -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();
index dd5f9229f68b610469b9506070a713270ec9ac86..fa86ab7383cace2b5c8057d1428a1bb56b77c152 100644 (file)
@@ -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();
index 58e0f1fc932a8eba2d25cd9ff6d48a627726f23d..139a1811db0665783cbcb305f83a30e7a1dad53f 100644 (file)
@@ -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);
index 22d42067d658e27fbd48cf2a6c4d5ee64eec83a6..8cf45ad5e94184b5af5f4a1da85514a14f13951e 100644 (file)
@@ -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{} );