From: Justin Lebar Date: Fri, 29 Jun 2018 22:28:09 +0000 (+0000) Subject: [CUDA] Make __host__/__device__ min/max overloads constexpr in C++14. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5aa4b4257a7bda80ecc229f8f66fddfa17c93b5;p=clang [CUDA] Make __host__/__device__ min/max overloads constexpr in C++14. Summary: Tests in a separate change to the test-suite. Reviewers: rsmith, tra Subscribers: lahwaacz, sanjoy, cfe-commits Differential Revision: https://reviews.llvm.org/D48151 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336026 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/cuda_wrappers/algorithm b/lib/Headers/cuda_wrappers/algorithm index d8658bf1c7..01af18360d 100644 --- a/lib/Headers/cuda_wrappers/algorithm +++ b/lib/Headers/cuda_wrappers/algorithm @@ -67,34 +67,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif #endif +#pragma push_macro("_CPP14_CONSTEXPR") +#if __cplusplus >= 201402L +#define _CPP14_CONSTEXPR constexpr +#else +#define _CPP14_CONSTEXPR +#endif + template __attribute__((enable_if(true, ""))) -inline __host__ __device__ const __T & +inline _CPP14_CONSTEXPR __host__ __device__ const __T & max(const __T &__a, const __T &__b, __Cmp __cmp) { return __cmp(__a, __b) ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __host__ __device__ const __T & +inline _CPP14_CONSTEXPR __host__ __device__ const __T & max(const __T &__a, const __T &__b) { return __a < __b ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __host__ __device__ const __T & +inline _CPP14_CONSTEXPR __host__ __device__ const __T & min(const __T &__a, const __T &__b, __Cmp __cmp) { return __cmp(__b, __a) ? __b : __a; } template __attribute__((enable_if(true, ""))) -inline __host__ __device__ const __T & +inline _CPP14_CONSTEXPR __host__ __device__ const __T & min(const __T &__a, const __T &__b) { return __a < __b ? __a : __b; } +#pragma pop_macro("_CPP14_CONSTEXPR") + #ifdef _LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD #else