From ee9f90005b4abef2c3bc4c0d063a8d67f0d18a5b Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 31 Mar 2026 11:11:45 -0400 Subject: [PATCH] NVHPC: Add detection of C++ 26 mode This compiler uses GCC's standard library, and so limits `__cplusplus` to that of the GCC toolchain. However, it defines feature macros that we can use to distinguish this mode. --- Modules/CMakeCXXCompilerId.cpp.in | 4 +++- Tests/CompileFeatures/cxx_std.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 4d78c2abf8..2e08785004 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -63,7 +63,9 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; # define CXX_STD __cplusplus # endif #elif defined(__NVCOMPILER) -# if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init) +# if __cplusplus > CXX_STD_20 && defined(__cpp_pp_embed) +# define CXX_STD /*CXX_STD_26*/ (CXX_STD_23 + 1) +# elif __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init) # define CXX_STD CXX_STD_20 # else # define CXX_STD __cplusplus diff --git a/Tests/CompileFeatures/cxx_std.h b/Tests/CompileFeatures/cxx_std.h index f17b683b61..c9d9ecfdcc 100644 --- a/Tests/CompileFeatures/cxx_std.h +++ b/Tests/CompileFeatures/cxx_std.h @@ -28,7 +28,9 @@ # define CXX_STD __cplusplus # endif #elif defined(__NVCOMPILER) -# if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init) +# if __cplusplus > CXX_STD_20 && defined(__cpp_pp_embed) +# define CXX_STD /*CXX_STD_26*/ (CXX_STD_23 + 1) +# elif __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init) # define CXX_STD CXX_STD_20 # else # define CXX_STD __cplusplus