[PATCH] D61949: [OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

Johannes Doerfert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 15 09:11:44 PDT 2019


jdoerfert added a comment.

Missing `defined(__cplusplus)` to avoid warnings and we have to resolve the two new includes. Otherwise, this looks good. So, if you "fix" both go ahead and commit, if not, lets discuss.



================
Comment at: lib/Headers/__clang_cuda_device_functions.h:1477
 #endif // CUDA_VERSION >= 9020
+#if __cplusplus >= 201703L
+__DEVICE__ int abs(int __a) noexcept { return __nv_abs(__a); }
----------------
Hahnfeld wrote:
> If I recall correctly, `__cplusplus` is not defined in C mode, so both GCC and Clang will issue a warning with `-Wundef`.
> 
> Maybe this can be solved with something similar to:
> ```lang=c
> #ifdef __cplusplus
> #define cpp_version __cplusplus
> #else
> #define cpp_version 0
> #endif
> ```
> (to avoid repetition of `#if defined(__cplusplus) && __cplusplus >= 201703L`)
I dislike defining the version and advice to repeating `#if defined(__cplusplus) && __cplusplus >= 201703L)`



================
Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:24
+  #include <cstdlib>
+  #include <stdlib.h>
 #endif
----------------
I ask this question again and again, do we need them now? Why?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61949/new/

https://reviews.llvm.org/D61949





More information about the cfe-commits mailing list