Skip to content

[libcxx][c++26] 2937R0: Freestanding: Remove strtok #146290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
96e2874
[libcxx cstring] make strtok not freestanding
dywoq Jun 29, 2025
0ccdf36
Merge branch 'main' of https://github.com/dywoq/llvm-project
dywoq Jun 29, 2025
311aac1
[libcxx] change the if/endif macro condition in cstring
dywoq Jun 29, 2025
b42c795
[libcxx] remove comment in cstring.freestanding test
dywoq Jun 29, 2025
ea22732
Merge branch 'llvm:main' into main
dywoq Jun 29, 2025
3afaa82
Merge branch 'llvm:main' into main
dywoq Jun 29, 2025
e4d20ce
[libcxx] add feature test macro __cpp_lib_freestanding_cstring
dywoq Jun 29, 2025
bb49355
Merge branch 'llvm:main' into main
dywoq Jun 29, 2025
10aca15
[libcxx] update synopsis in <version> header
dywoq Jun 29, 2025
7fee8c9
Merge branch 'main' of https://github.com/dywoq/llvm-project
dywoq Jun 29, 2025
8631890
Update libcxx/test/std/cstring/freestanding/strtok_removed.fail.cpp
dywoq Jun 29, 2025
5fb0ca5
[libcxx] change c++ standard to c++2c in strtok_removed.fail.cpp
dywoq Jun 29, 2025
d059b9d
[libcxx] update synopsis in cstring
dywoq Jun 30, 2025
dba6efa
[libcxx] update generate_feature_test_macro_components.py
dywoq Jun 30, 2025
97a7e41
[libcxx] remove extra colon
dywoq Jun 30, 2025
fb1f355
[libcxx] remove L at the end of number
dywoq Jun 30, 2025
15ab8ec
[libcxx] update <verison> header
dywoq Jun 30, 2025
683c0f7
Merge branch 'main' into main
dywoq Jun 30, 2025
0a33018
[libcxx] remove the macro condition in <cstring>
dywoq Jun 30, 2025
1e49426
[libcxx] rename strtok_removed.fail.cpp to strtok_removed.verify.cpp
dywoq Jun 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/include/cstring
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const char* strrchr(const char* s, int c);
size_t strspn(const char* s1, const char* s2);
const char* strstr(const char* s1, const char* s2);
char* strstr( char* s1, const char* s2);
char* strtok(char* restrict s1, const char* restrict s2);
char* strtok(char* restrict s1, const char* restrict s2); // not freestanding
void* memset(void* s, int c, size_t n);
char* strerror(int errnum);
size_t strlen(const char* s);
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ __cpp_lib_formatters 202302L <stacktrace> <th
__cpp_lib_forward_like 202207L <utility>
__cpp_lib_freestanding_algorithm 202311L <algorithm>
__cpp_lib_freestanding_array 202311L <array>
__cpp_lib_freestanding_cstring 202306L <cstring>
__cpp_lib_freestanding_cstring 202307L <cstring>
__cpp_lib_freestanding_expected 202311L <expected>
__cpp_lib_freestanding_mdspan 202311L <mdspan>
__cpp_lib_freestanding_optional 202311L <optional>
Expand Down Expand Up @@ -558,7 +558,7 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_format_path 202403L
// # define __cpp_lib_freestanding_algorithm 202311L
// # define __cpp_lib_freestanding_array 202311L
// # define __cpp_lib_freestanding_cstring 202306L
// # define __cpp_lib_freestanding_cstring 202307L
// # define __cpp_lib_freestanding_expected 202311L
// # define __cpp_lib_freestanding_mdspan 202311L
// # define __cpp_lib_freestanding_optional 202311L
Expand Down
14 changes: 14 additions & 0 deletions libcxx/test/std/cstring/freestanding/strtok_removed.verify.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
// REQUIRES: c++2c
// XFAIL: *

// RUN: %clang %s -c -o /dev/null -ffreestanding --std=c++2c 2>&1

#include <cstring>

int main() {
char s[] = "hello world";
char* tok = std::strtok(s, " ");
(void)tok;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
# ifndef __cpp_lib_freestanding_cstring
# error "__cpp_lib_freestanding_cstring should be defined in c++26"
# endif
# if __cpp_lib_freestanding_cstring != 202306L
# error "__cpp_lib_freestanding_cstring should have the value 202306L in c++26"
# if __cpp_lib_freestanding_cstring != 202307L
# error "__cpp_lib_freestanding_cstring should have the value 202307L in c++26"
# endif
# else
# ifdef __cpp_lib_freestanding_cstring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6809,8 +6809,8 @@
# ifndef __cpp_lib_freestanding_cstring
# error "__cpp_lib_freestanding_cstring should be defined in c++26"
# endif
# if __cpp_lib_freestanding_cstring != 202306L
# error "__cpp_lib_freestanding_cstring should have the value 202306L in c++26"
# if __cpp_lib_freestanding_cstring != 202307L
# error "__cpp_lib_freestanding_cstring should have the value 202307L in c++26"
# endif
# else
# ifdef __cpp_lib_freestanding_cstring
Expand Down
3 changes: 2 additions & 1 deletion libcxx/utils/generate_feature_test_macro_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ def add_version_header(tc):
{
"name": "__cpp_lib_freestanding_cstring",
"values": {
"c++26": 202306 # P2338R4 Freestanding Library: Character primitives and the C library
"c++26": 202307 # P2937R0 Freestanding: Remove strtok
# 202306 # P2338R4 Freestanding Library: Character primitives and the C library
# 202311 # P2407R5 Freestanding Library: Partial Classes
},
"headers": ["cstring"],
Expand Down