From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3497A385C405 for ; Tue, 21 Nov 2023 16:11:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3497A385C405 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 3497A385C405 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700583102; cv=none; b=U95MNi14DbFrHWlU86rUHinKp11v91RkNwEE4iaxPIL8rZRePEjdsdOdfUQC874q5Z6QCMu9FrCaB/prCVKozEQ7gI2JPat4e0+yrEGW4TeG90cBEHf5ID/WzPaycIw2Do4MObT0h63owv6zAtoGTI06+XRaSGhqp5n33R1g/Hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700583102; c=relaxed/simple; bh=NlxJKQUYLILt1riZMwNn5+cNTCq4WA2Hwnhp1PmlrvE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ALVPm+nahWWx+Wjrn4m7Paz5+GiRp2nVNVbUhdqFPdrfmHpnxBsASOquAaekZIpSrl2edQiRfZRzrh/6tQHz59I8gJIXaXALnw3T3mB5z8JmJGZi96/lJS8Em7s4jPXahC33RZdkwALuEP49aqlSScghyuSpHBV+qQ+z+6EESpI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700583099; 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; bh=4wewL4LA5/eqeRoMVG9LhTuC8YIO32x2Qnv779YZhMg=; b=MZdycgXfXQJv5PKxKcN/DBIcRk54E7AL0G/fuUgm0oytaJnoqzZ799OGjMFAJqiVSGOWc0 cepYdWGKI4ujYRAgLYBLpH7nOKSnnuKXGiBhWlkjq2FU2XKvZJc3gfkTakzknmkmBi0lrw D8flQhNB8+L8kSfmdmHf+Amc7Scq7FU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-489-4Ww8moEuMUC9eva0f3SdyQ-1; Tue, 21 Nov 2023 11:11:38 -0500 X-MC-Unique: 4Ww8moEuMUC9eva0f3SdyQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id C83FC85A58C; Tue, 21 Nov 2023 16:11:37 +0000 (UTC) Received: from localhost (unknown [10.42.28.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C2492026D4C; Tue, 21 Nov 2023 16:11:37 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Do not declare strtok for C++26 freestanding (P2937R0) Date: Tue, 21 Nov 2023 16:11:07 +0000 Message-ID: <20231121161136.2031190-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested x86_64-linux. Pushed to trunk. -- >8 -- This was recently approved for C++26. We should define the __cpp_lib_freestanding_cstring macro in as well as , but we do not currently install our own for most targets. libstdc++-v3/ChangeLog: * include/bits/version.def (freestanding_cstring): Add. * include/bits/version.h: Regenerate. * include/c_compatibility/string.h (strtok): Do not declare for C++26 freestanding. * include/c_global/cstring (strtok): Likewise. * testsuite/21_strings/headers/cstring/version.cc: New test. --- libstdc++-v3/include/bits/version.def | 9 ++ libstdc++-v3/include/bits/version.h | 89 +++++++++++-------- libstdc++-v3/include/c_compatibility/string.h | 2 + libstdc++-v3/include/c_global/cstring | 5 +- .../21_strings/headers/cstring/version.cc | 19 ++++ 5 files changed, 84 insertions(+), 40 deletions(-) create mode 100644 libstdc++-v3/testsuite/21_strings/headers/cstring/version.cc diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 1c49ecea25e..605708dfee7 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -1366,6 +1366,15 @@ ftms = { }; }; +ftms = { + name = freestanding_cstring; + values = { + v = 202311; + // This is a C++26 feature, but we support it in C++23. + cxxmin = 23; + }; +}; + ftms = { name = freestanding_expected; values = { diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index a61d482c662..cacd9375cab 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -1653,6 +1653,17 @@ #undef __glibcxx_want_freestanding_array // from version.def line 1370 +#if !defined(__cpp_lib_freestanding_cstring) +# if (__cplusplus >= 202100L) +# define __glibcxx_freestanding_cstring 202311L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_freestanding_cstring) +# define __cpp_lib_freestanding_cstring 202311L +# endif +# endif +#endif /* !defined(__cpp_lib_freestanding_cstring) && defined(__glibcxx_want_freestanding_cstring) */ +#undef __glibcxx_want_freestanding_cstring + +// from version.def line 1379 #if !defined(__cpp_lib_freestanding_expected) # if (__cplusplus >= 202100L) && (__cpp_lib_expected) # define __glibcxx_freestanding_expected 202311L diff --git a/libstdc++-v3/include/c_compatibility/string.h b/libstdc++-v3/include/c_compatibility/string.h index 1d9e0d2a9bd..06529af057c 100644 --- a/libstdc++-v3/include/c_compatibility/string.h +++ b/libstdc++-v3/include/c_compatibility/string.h @@ -50,7 +50,9 @@ using std::strpbrk; using std::strrchr; using std::strspn; using std::strstr; +#if _GLIBCXX_HOSTED || __cplusplus <= 202302L using std::strtok; +#endif using std::memset; using std::strerror; using std::strlen; diff --git a/libstdc++-v3/include/c_global/cstring b/libstdc++-v3/include/c_global/cstring index d0a129ac802..f39aae1c82e 100644 --- a/libstdc++-v3/include/c_global/cstring +++ b/libstdc++-v3/include/c_global/cstring @@ -38,7 +38,8 @@ #pragma GCC system_header -#include +#define __glibcxx_want_freestanding_cstring +#include #include #ifndef _GLIBCXX_CSTRING @@ -90,7 +91,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using ::strncmp; using ::strncpy; using ::strspn; +#if _GLIBCXX_HOSTED || __cplusplus <= 202302L using ::strtok; +#endif using ::strxfrm; using ::strchr; using ::strpbrk; diff --git a/libstdc++-v3/testsuite/21_strings/headers/cstring/version.cc b/libstdc++-v3/testsuite/21_strings/headers/cstring/version.cc new file mode 100644 index 00000000000..06735e86a76 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/headers/cstring/version.cc @@ -0,0 +1,19 @@ +// { dg-do compile { target c++26 } } +// { dg-add-options no_pch } + +#include + +#ifndef __cpp_lib_freestanding_cstring +# error "Feature test macro for freestanding is missing in " +#elif __cpp_lib_freestanding_cstring < 202311L +# error "Feature test macro for freestanding has wrong value in " +#endif + +#undef __cpp_lib_freestanding_cstring +#include + +#ifndef __cpp_lib_freestanding_cstring +# error "Feature test macro for freestanding is missing in " +#elif __cpp_lib_freestanding_cstring < 202311L +# error "Feature test macro for freestanding has wrong value in " +#endif -- 2.42.0