diff options
author | Tomasz Kamiński <tkaminsk@redhat.com> | 2025-04-22 09:56:42 +0200 |
---|---|---|
committer | Tomasz Kamiński <tkaminsk@redhat.com> | 2025-04-25 13:38:45 +0200 |
commit | 17e0decc1dbf827747aebfa0573cc8e50969ae3f (patch) | |
tree | 29ab952b3d39eee5cd8d1c1431c8c51919d8c259 | |
parent | 5bd02daf8430ecce1d7fd847ef4fc9c369179542 (diff) | |
download | gcc-17e0decc1dbf827747aebfa0573cc8e50969ae3f.zip gcc-17e0decc1dbf827747aebfa0573cc8e50969ae3f.tar.gz gcc-17e0decc1dbf827747aebfa0573cc8e50969ae3f.tar.bz2 |
libstdc++: Define __cpp_lib_format_ranges in format header [PR109162]
As P2286R8 and P2585R1 as now fully implemented, we now define
__cpp_lib_format_ranges feature test macro with __cpp_lib_format_ranges.
This macro is provided only in <format>.
Uses of internal __glibcxx_format_ranges are also updated.
PR libstdc++/109162
libstdc++-v3/ChangeLog:
* include/bits/version.def (format_ranges): Remove no_stdname and
update value.
* include/bits/version.h: Regenerate.
* src/c++23/std.cc.in: Replace __glibcxx_format_ranges with
__cpp_lib_format_ranges.
* testsuite/std/format/formatter/lwg3944.cc: Likewise.
* testsuite/std/format/parse_ctx.cc: Likewise.
* testsuite/std/format/string.cc: Likewise.
* testsuite/std/format/ranges/feature_test.cc: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
(cherry picked from commit 049fefd7e1501ac9dcc66a5ef6c34cea0331dc43)
-rw-r--r-- | libstdc++-v3/include/bits/version.def | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/version.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/src/c++23/std.cc.in | 6 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/std/format/formatter/lwg3944.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/std/format/parse_ctx.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/std/format/ranges/feature_test.cc | 9 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/std/format/string.cc | 2 |
7 files changed, 17 insertions, 10 deletions
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 0afaf0d..737b3f4 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -1416,9 +1416,8 @@ ftms = { // 202207 P2286R8 Formatting Ranges // 202207 P2585R1 Improving default container formatting // LWG3750 Too many papers bump __cpp_lib_format - no_stdname = true; // TODO remove values = { - v = 1; // TODO 202207 + v = 202207; cxxmin = 23; hosted = yes; }; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 980fee6..59ff0ce 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -1562,8 +1562,9 @@ #if !defined(__cpp_lib_format_ranges) # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED -# define __glibcxx_format_ranges 1L +# define __glibcxx_format_ranges 202207L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_format_ranges) +# define __cpp_lib_format_ranges 202207L # endif # endif #endif /* !defined(__cpp_lib_format_ranges) && defined(__glibcxx_want_format_ranges) */ diff --git a/libstdc++-v3/src/c++23/std.cc.in b/libstdc++-v3/src/c++23/std.cc.in index 5e18ad7..6da6d38 100644 --- a/libstdc++-v3/src/c++23/std.cc.in +++ b/libstdc++-v3/src/c++23/std.cc.in @@ -1315,8 +1315,7 @@ export namespace std using std::format_to_n; using std::format_to_n_result; using std::formatted_size; -// FIXME __cpp_lib_format_ranges -#if __cplusplus > 202002L +#if __cpp_lib_format_ranges using std::formattable; #endif using std::formatter; @@ -1332,8 +1331,7 @@ export namespace std using std::wformat_context; using std::wformat_parse_context; using std::wformat_string; -// FIXME __cpp_lib_format_ranges -#ifdef __glibcxx_format_ranges +#ifdef __cpp_lib_format_ranges using std::format_kind; using std::range_format; using std::range_formatter; diff --git a/libstdc++-v3/testsuite/std/format/formatter/lwg3944.cc b/libstdc++-v3/testsuite/std/format/formatter/lwg3944.cc index 1f3edc9..07e63af 100644 --- a/libstdc++-v3/testsuite/std/format/formatter/lwg3944.cc +++ b/libstdc++-v3/testsuite/std/format/formatter/lwg3944.cc @@ -18,7 +18,7 @@ void test_lwg3944() std::format(L"{}", "hello"); // { dg-error "here" } std::format(L"{}", std::string_view("hello")); // { dg-error "here" } std::format(L"{}", std::string("hello")); // { dg-error "here" } -#ifdef __glibcxx_format_ranges +#ifdef __cpp_lib_format_ranges // LWG 3944 does not change this, it's still valid. std::format(L"{}", std::vector{'h', 'e', 'l', 'l', 'o'}); #endif diff --git a/libstdc++-v3/testsuite/std/format/parse_ctx.cc b/libstdc++-v3/testsuite/std/format/parse_ctx.cc index b338ac7..b5dd7cd 100644 --- a/libstdc++-v3/testsuite/std/format/parse_ctx.cc +++ b/libstdc++-v3/testsuite/std/format/parse_ctx.cc @@ -108,7 +108,7 @@ is_std_format_spec_for(std::string_view spec) } } -#if __glibcxx_format_ranges +#if __cpp_lib_format_ranges constexpr bool escaped_strings_supported = true; #else constexpr bool escaped_strings_supported = false; diff --git a/libstdc++-v3/testsuite/std/format/ranges/feature_test.cc b/libstdc++-v3/testsuite/std/format/ranges/feature_test.cc new file mode 100644 index 0000000..80d2cea --- /dev/null +++ b/libstdc++-v3/testsuite/std/format/ranges/feature_test.cc @@ -0,0 +1,9 @@ +// { dg-do preprocess { target c++23 } } + +#include <format> + +#ifndef __cpp_lib_format_ranges +# error "Feature-test macro __cpp_lib_format_ranges missing in <format>" +#elif __cpp_lib_format_ranges != 202207L +# error "Feature-test macro __cpp_lib_format_ranges has wrong value in <format>" +#endif diff --git a/libstdc++-v3/testsuite/std/format/string.cc b/libstdc++-v3/testsuite/std/format/string.cc index 76614d4..ee987a1 100644 --- a/libstdc++-v3/testsuite/std/format/string.cc +++ b/libstdc++-v3/testsuite/std/format/string.cc @@ -62,7 +62,7 @@ test_indexing() VERIFY( ! is_format_string_for("{} {0}", 1) ); } -#if __glibcxx_format_ranges +#if __cpp_lib_format_ranges constexpr bool escaped_strings_supported = true; #else constexpr bool escaped_strings_supported = false; |