Skip to content

Commit 1e76531

Browse files
committed
cpp: add kconfig option STD_CPP23 for STD_CPP
to be able to choose c++23 dialect deprecates c++2b, but we should keep the option c++2b for legacy Signed-off-by: Adrian Bieri <adrian.bieri@loepfe.com>
1 parent 47b07e5 commit 1e76531

File tree

8 files changed

+22
-4
lines changed

8 files changed

+22
-4
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ if(CONFIG_CPP)
302302
elseif(CONFIG_STD_CPP2B)
303303
set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp2b>)
304304
list(APPEND CMAKE_CXX_COMPILE_FEATURES ${compile_features_cpp20})
305+
elseif(CONFIG_STD_CPP23)
306+
set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp23>)
307+
list(APPEND CMAKE_CXX_COMPILE_FEATURES ${compile_features_cpp23})
305308
else()
306309
message(FATAL_ERROR
307310
"Unreachable code. Expected C++ standard to have been chosen. See Kconfig.zephyr.")

cmake/compiler/arcmwdt/compiler_flags.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp11 "-std=c++11")
127127
set_property(TARGET compiler-cpp PROPERTY dialect_cpp14 "-std=c++14")
128128
set_property(TARGET compiler-cpp PROPERTY dialect_cpp17 "-std=c++17")
129129

130-
#no support of C++2a, C++20, C++2b
130+
# no support of C++2a, C++20, C++2b, C++23
131131
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a "")
132132
set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 "")
133133
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b "")
134+
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23 "")
134135

135136
# Flag for disabling strict aliasing rule in C and C++
136137
set_compiler_property(PROPERTY no_strict_aliasing -fno-strict-aliasing)

cmake/compiler/compiler_features.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ set(compile_features_cpp11 cxx_std_11 ${compile_features_cpp98})
2424
set(compile_features_cpp14 cxx_std_14 ${compile_features_cpp11})
2525
set(compile_features_cpp17 cxx_std_17 ${compile_features_cpp14})
2626
set(compile_features_cpp20 cxx_std_20 ${compile_features_cpp17})
27+
set(compile_features_cpp23 cxx_std_23 ${compile_features_cpp20})

cmake/compiler/compiler_flags_template.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp17)
6868
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a)
6969
set_property(TARGET compiler-cpp PROPERTY dialect_cpp20)
7070
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b)
71+
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23)
7172

7273
# Flag for disabling strict aliasing rule in C and C++
7374
set_compiler_property(PROPERTY no_strict_aliasing)

cmake/compiler/gcc/compiler_flags.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 "-std=c++20"
146146
"-Wno-register" "-Wno-volatile")
147147
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b "-std=c++2b"
148148
"-Wno-register" "-Wno-volatile")
149+
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23 "-std=c++23"
150+
"-Wno-register" "-Wno-volatile")
149151

150152
# Flag for disabling strict aliasing rule in C and C++
151153
set_compiler_property(PROPERTY no_strict_aliasing -fno-strict-aliasing)

cmake/compiler/iar/compiler_flags.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp17 --libc++)
120120
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a --libc++)
121121
set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 --libc++)
122122
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b --libc++)
123+
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23 --libc++)
123124

124125
# Flag for disabling strict aliasing rule in C and C++
125126
set_compiler_property(PROPERTY no_strict_aliasing)

lib/cpp/Kconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ config STD_CPP_VERSION
1818
default 201103 if STD_CPP11
1919
default 201402 if STD_CPP14
2020
default 201703 if STD_CPP17
21-
default 202002 if STD_CPP20 || STD_CPP2A || STD_CPP2B
21+
default 202002 if STD_CPP20 || STD_CPP2A
22+
default 202302 if STD_CPP23 || STD_CPP2B
2223
help
2324
The version number of C++ standard being used (NOTE: this uses the
2425
full year and month, and is the same as the __cplusplus macro defined
@@ -75,6 +76,11 @@ config STD_CPP2B
7576
help
7677
Next revision of the C++ standard, which is expected to be published in 2023.
7778

79+
config STD_CPP23
80+
bool "C++ 23"
81+
help
82+
2023 C++ standard, previously known as C++2B.
83+
7884
endchoice
7985

8086
config REQUIRES_FULL_LIBCPP

tests/lib/cpp/cxx/testcase.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ tests:
7070
- CONFIG_STD_CPP20=y
7171
cpp.main.cpp2B:
7272
arch_exclude: posix
73-
toolchain_exclude:
74-
- xt-clang
7573
build_only: true
7674
extra_configs:
7775
- CONFIG_STD_CPP2B=y
76+
cpp.main.cpp23:
77+
arch_exclude: posix
78+
build_only: true
79+
extra_configs:
80+
- CONFIG_STD_CPP23=y

0 commit comments

Comments
 (0)