From 3587579f34235255db11a2d2b11668829f256790 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 3 Apr 2024 14:26:18 -0400 Subject: XL/XLClang: Fix detection of C++ 14 mode on Linux This compiler does not always define `__cplusplus` correctly, but does define a feature macro that we can use to distinguish this mode. --- Modules/CMakeCXXCompilerId.cpp.in | 6 ++++++ Tests/CompileFeatures/default_dialect.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 3a334ed..2a92287 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -66,6 +66,12 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; # else # define CXX_STD __cplusplus # endif +#elif (defined(__IBMCPP__) || defined(__ibmxl__)) && defined(__linux__) +# if __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi) +# define CXX_STD CXX_STD_14 +# else +# define CXX_STD __cplusplus +# endif #else # define CXX_STD __cplusplus #endif diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 82a8698..081b049 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -35,6 +35,12 @@ struct Outputter; # else # define CXX_STD __cplusplus # endif +#elif (defined(__IBMCPP__) || defined(__ibmxl__)) && defined(__linux__) +# if __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi) +# define CXX_STD CXX_STD_14 +# else +# define CXX_STD __cplusplus +# endif #else # define CXX_STD __cplusplus #endif -- cgit v0.12