aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-07-12 00:30:24 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2024-07-31 17:07:10 +0100
commit72cd15b20a887bed9b0b1f4196be99fe052247b4 (patch)
tree2a6530a0e43f98671d9d9b65c10cfca8617b21cc
parent74b5101cc9e297f7c530642553e3498d4d705cf4 (diff)
downloadgcc-72cd15b20a887bed9b0b1f4196be99fe052247b4.zip
gcc-72cd15b20a887bed9b0b1f4196be99fe052247b4.tar.gz
gcc-72cd15b20a887bed9b0b1f4196be99fe052247b4.tar.bz2
libstdc++: Support P2510R3 "Formatting pointers" as a DR for C++20
We already enable this for -std=gnu++20 but we can do it for -std=c++20 too. Both libc++ and MSVC also treat this change as a DR for C++20. Now that the previous change to the value of __cpp_lib_format is supported, we can finally update it to 202304 to indicate support for this feature too. libstdc++-v3/ChangeLog: * include/bits/version.def (format): Update value for P2510R3. * include/bits/version.h: Regenerate. * include/std/format (_GLIBCXX_P2518R3): Remove misspelled macro and check __glibcxx_format instead. * testsuite/std/format/functions/format.cc: Check value of the __cpp_lib_format macro for formatting pointers support. * testsuite/std/format/parse_ctx.cc: Likewise.
-rw-r--r--libstdc++-v3/include/bits/version.def6
-rw-r--r--libstdc++-v3/include/bits/version.h4
-rw-r--r--libstdc++-v3/include/std/format16
-rw-r--r--libstdc++-v3/testsuite/std/format/functions/format.cc2
-rw-r--r--libstdc++-v3/testsuite/std/format/parse_ctx.cc4
5 files changed, 12 insertions, 20 deletions
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 7494730..1acc9cd 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -1162,12 +1162,11 @@ ftms = {
ftms = {
name = format;
- // 202304 P2510R3 Formatting pointers
// 202305 P2757R3 Type checking format args
// 202306 P2637R3 Member visit
// 202311 P2918R2 Runtime format strings II
// values = {
- // v = 202304;
+ // v = 202305;
// cxxmin = 26;
// hosted = yes;
// };
@@ -1175,8 +1174,9 @@ ftms = {
// 202106 std::format improvements.
// 202110 Fixing locale handling in chrono formatters, generator-like types.
// 202207 Encodings in localized formatting of chrono, basic-format-string.
+ // 202304 P2510R3 Formatting pointers
values = {
- v = 202207;
+ v = 202304;
cxxmin = 20;
hosted = yes;
};
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 9f86733..5cd7777 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -1305,9 +1305,9 @@
#if !defined(__cpp_lib_format)
# if (__cplusplus >= 202002L) && _GLIBCXX_HOSTED
-# define __glibcxx_format 202207L
+# define __glibcxx_format 202304L
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_format)
-# define __cpp_lib_format 202207L
+# define __cpp_lib_format 202304L
# endif
# endif
#endif /* !defined(__cpp_lib_format) && defined(__glibcxx_want_format) */
diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index fe00e54..2669ad8 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -2342,13 +2342,7 @@ namespace __format
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// P2510R3 Formatting pointers
-#if __glibcxx_format >= 202304L || ! defined __STRICT_ANSI__
-# define _GLIBCXX_P2518R3 1
-#else
-# define _GLIBCXX_P2518R3 0
-#endif
-
-#if _GLIBCXX_P2518R3
+#if __glibcxx_format >= 202304L
__first = __spec._M_parse_zero_fill(__first, __last);
if (__finished())
return __first;
@@ -2360,11 +2354,9 @@ namespace __format
{
if (*__first == 'p')
++__first;
-#if _GLIBCXX_P2518R3
+#if __glibcxx_format >= 202304L
else if (*__first == 'P')
{
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // P2510R3 Formatting pointers
__spec._M_type = __format::_Pres_P;
++__first;
}
@@ -2388,7 +2380,7 @@ namespace __format
int __n = __ptr - __buf;
__buf[0] = '0';
__buf[1] = 'x';
-#if _GLIBCXX_P2518R3
+#if __glibcxx_format >= 202304L
if (_M_spec._M_type == __format::_Pres_P)
{
__buf[1] = 'X';
@@ -2413,7 +2405,7 @@ namespace __format
}
#endif
-#if _GLIBCXX_P2518R3
+#if __glibcxx_format >= 202304L
if (_M_spec._M_zero_fill)
{
size_t __width = _M_spec._M_get_width(__fc);
diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc
index 78cc1ab..5152bb0 100644
--- a/libstdc++-v3/testsuite/std/format/functions/format.cc
+++ b/libstdc++-v3/testsuite/std/format/functions/format.cc
@@ -458,7 +458,7 @@ test_pointer()
s = std::format("{:20} {:20p}", p, pc);
VERIFY( s == (str_int + ' ' + str_int) );
-#if __cplusplus > 202302L || ! defined __STRICT_ANSI__
+#if __cpp_lib_format >= 202304L
// P2510R3 Formatting pointers
s = std::format("{:06} {:07P} {:08p}", (void*)0, (const void*)0, nullptr);
VERIFY( s == "0x0000 0X00000 0x000000" );
diff --git a/libstdc++-v3/testsuite/std/format/parse_ctx.cc b/libstdc++-v3/testsuite/std/format/parse_ctx.cc
index 497427b..3b3201c 100644
--- a/libstdc++-v3/testsuite/std/format/parse_ctx.cc
+++ b/libstdc++-v3/testsuite/std/format/parse_ctx.cc
@@ -266,8 +266,8 @@ test_pointer()
VERIFY( ! is_std_format_spec_for<void*>("G") );
VERIFY( ! is_std_format_spec_for<void*>("+p") );
-#if __cplusplus > 202302L || ! defined __STRICT_ANSI__
- // As an extension, we support P2510R3 Formatting pointers
+#if __cpp_lib_format >= 202304L
+ // P2510R3 Formatting pointers
VERIFY( is_std_format_spec_for<void*>("P") );
VERIFY( is_std_format_spec_for<void*>("0p") );
VERIFY( is_std_format_spec_for<void*>("0P") );