From patchwork Tue Jul 16 11:55:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1961058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JqaL+W5o; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNd7P458Yz1xrQ for ; Tue, 16 Jul 2024 22:05:37 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E4E863839143 for ; Tue, 16 Jul 2024 12:05:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id F28A3384A4B6 for ; Tue, 16 Jul 2024 12:04:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F28A3384A4B6 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F28A3384A4B6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721131495; cv=none; b=wHPxX5TJHOE5lqWvwdLh+yASopPTI9RUHdsKcEYFvO0rKROSXLL40vrHmJR4wRKA+2IV7KENn+OAdNqkuDze7djXiwLpJxXRm7FQM69l+52ezxnoIdku669YmVIERCmCiHX1b1N9OQpNhKZo1whmevfrO2AxPl9uC8dzgyM/Uhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721131495; c=relaxed/simple; bh=Bn/jgeY8g2MNOO+Yy+55CBlzhhMNoPGbQ9tuLLzr42c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WyP3su/DmkynyjqvJ66sFDqDO8C6WmJSrv+tbFoCN1W7DUMlgnliL1nZfOSrlTJZ4vrjxb5LC/lfCMcDZeAcUQ25PP10+axlJ03KAYSQUhH+dXQyx3NjGyRfV08m43oq/+1F1eXDrxV2iSWvjqBFMobSl55FkEq7pQuqFZjZldo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721131484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M+KcO7glLsAOU2Ycr7c4L+lMF0NPGQxeuW16L7tcIIQ=; b=JqaL+W5oNFug5+SL0N/PesNH6Q4ru7CNbhfv9XsUJNC+LAjBKCJO6KlRCbW5H2jDgE5i5p KBjbRTrZ6kTPQp931U7BQ21le3YG8dnEcSeHc1OppvI/lmz1SJzJj6Zirq3w3VZy/34M/u rhr10uKHQrO0Hf67qxuNdM9r/wgu+Bk= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-3VRLIIqiNO-1dZ0JbXndcw-1; Tue, 16 Jul 2024 08:04:43 -0400 X-MC-Unique: 3VRLIIqiNO-1dZ0JbXndcw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B3D0619560A2; Tue, 16 Jul 2024 12:04:41 +0000 (UTC) Received: from localhost (unknown [10.42.28.14]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1B78A1955F40; Tue, 16 Jul 2024 12:04:40 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 2/6] libstdc++: Support P2510R3 "Formatting pointers" as a DR for C++20 Date: Tue, 16 Jul 2024 12:55:58 +0100 Message-ID: <20240716120436.2135312-2-jwakely@redhat.com> In-Reply-To: <20240716120436.2135312-1-jwakely@redhat.com> References: <20240716120436.2135312-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-linux. -- >8 -- 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. --- libstdc++-v3/include/bits/version.def | 6 +++--- libstdc++-v3/include/bits/version.h | 4 ++-- libstdc++-v3/include/std/format | 16 ++++------------ .../testsuite/std/format/functions/format.cc | 2 +- libstdc++-v3/testsuite/std/format/parse_ctx.cc | 4 ++-- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 74947301760..1acc9cd5cb9 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 9f8673395da..5cd77770e21 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 a4921ce391b..487177b5294 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 78cc1ab482a..5152bb0b0d0 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 497427b54e5..3b3201c2a47 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("G") ); VERIFY( ! is_std_format_spec_for("+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("P") ); VERIFY( is_std_format_spec_for("0p") ); VERIFY( is_std_format_spec_for("0P") );