From c7cbe57e1f3a830ce53a0fe9f604adba11aa71e9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 8 Apr 2024 18:41:22 -0400 Subject: Clang: Fix detection of C++26 when targeting MSVC ABI `_MSVC_LANG` may not be defined higher than C++20, but `__cplusplus` is. --- Modules/CMakeCXXCompilerId.cpp.in | 6 +++++- Tests/CompileFeatures/cxx_std.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 390bf4e..6df15ac 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -57,7 +57,11 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; # define CXX_STD CXX_STD_98 # endif #elif defined(_MSC_VER) && defined(_MSVC_LANG) -# define CXX_STD _MSVC_LANG +# if _MSVC_LANG > __cplusplus +# define CXX_STD _MSVC_LANG +# else +# define CXX_STD __cplusplus +# endif #elif defined(__NVCOMPILER) # if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init) # define CXX_STD CXX_STD_20 diff --git a/Tests/CompileFeatures/cxx_std.h b/Tests/CompileFeatures/cxx_std.h index 1fc8579..f17b683 100644 --- a/Tests/CompileFeatures/cxx_std.h +++ b/Tests/CompileFeatures/cxx_std.h @@ -22,7 +22,11 @@ # define CXX_STD CXX_STD_98 # endif #elif defined(_MSC_VER) && defined(_MSVC_LANG) -# define CXX_STD _MSVC_LANG +# if _MSVC_LANG > __cplusplus +# define CXX_STD _MSVC_LANG +# else +# define CXX_STD __cplusplus +# endif #elif defined(__NVCOMPILER) # if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init) # define CXX_STD CXX_STD_20 -- cgit v0.12