Skip to content

cpp: add kconfig option STD_CPP23 for STD_CPP #93588

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 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ if(CONFIG_CPP)
elseif(CONFIG_STD_CPP2B)
set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp2b>)
list(APPEND CMAKE_CXX_COMPILE_FEATURES ${compile_features_cpp20})
elseif(CONFIG_STD_CPP23)
set(STD_CPP_DIALECT_FLAGS $<TARGET_PROPERTY:compiler-cpp,dialect_cpp23>)
list(APPEND CMAKE_CXX_COMPILE_FEATURES ${compile_features_cpp23})
else()
message(FATAL_ERROR
"Unreachable code. Expected C++ standard to have been chosen. See Kconfig.zephyr.")
Expand Down
3 changes: 2 additions & 1 deletion cmake/compiler/arcmwdt/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp11 "-std=c++11")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp14 "-std=c++14")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp17 "-std=c++17")

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

# Flag for disabling strict aliasing rule in C and C++
set_compiler_property(PROPERTY no_strict_aliasing -fno-strict-aliasing)
Expand Down
1 change: 1 addition & 0 deletions cmake/compiler/compiler_features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ set(compile_features_cpp11 cxx_std_11 ${compile_features_cpp98})
set(compile_features_cpp14 cxx_std_14 ${compile_features_cpp11})
set(compile_features_cpp17 cxx_std_17 ${compile_features_cpp14})
set(compile_features_cpp20 cxx_std_20 ${compile_features_cpp17})
set(compile_features_cpp23 cxx_std_23 ${compile_features_cpp20})
1 change: 1 addition & 0 deletions cmake/compiler/compiler_flags_template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp17)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp20)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23)

# Flag for disabling strict aliasing rule in C and C++
set_compiler_property(PROPERTY no_strict_aliasing)
Expand Down
2 changes: 2 additions & 0 deletions cmake/compiler/gcc/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 "-std=c++20"
"-Wno-register" "-Wno-volatile")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b "-std=c++2b"
"-Wno-register" "-Wno-volatile")
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23 "-std=c++23"
"-Wno-register" "-Wno-volatile")

# Flag for disabling strict aliasing rule in C and C++
set_compiler_property(PROPERTY no_strict_aliasing -fno-strict-aliasing)
Expand Down
1 change: 1 addition & 0 deletions cmake/compiler/iar/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ set_property(TARGET compiler-cpp PROPERTY dialect_cpp17 --libc++)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2a --libc++)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp20 --libc++)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp2b --libc++)
set_property(TARGET compiler-cpp PROPERTY dialect_cpp23 --libc++)

# Flag for disabling strict aliasing rule in C and C++
set_compiler_property(PROPERTY no_strict_aliasing)
Expand Down
8 changes: 7 additions & 1 deletion lib/cpp/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ config STD_CPP_VERSION
default 201103 if STD_CPP11
default 201402 if STD_CPP14
default 201703 if STD_CPP17
default 202002 if STD_CPP20 || STD_CPP2A || STD_CPP2B
default 202002 if STD_CPP20 || STD_CPP2A
default 202302 if STD_CPP23 || STD_CPP2B
help
The version number of C++ standard being used (NOTE: this uses the
full year and month, and is the same as the __cplusplus macro defined
Expand Down Expand Up @@ -75,6 +76,11 @@ config STD_CPP2B
help
Next revision of the C++ standard, which is expected to be published in 2023.

config STD_CPP23
bool "C++ 23"
help
2023 C++ standard, previously known as C++2B.

endchoice

config REQUIRES_FULL_LIBCPP
Expand Down
7 changes: 5 additions & 2 deletions tests/lib/cpp/cxx/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ tests:
- CONFIG_STD_CPP20=y
cpp.main.cpp2B:
arch_exclude: posix
toolchain_exclude:
- xt-clang
build_only: true
extra_configs:
- CONFIG_STD_CPP2B=y
cpp.main.cpp23:
arch_exclude: posix
build_only: true
extra_configs:
- CONFIG_STD_CPP23=y