[clang] Fix for OpenMP offloading compilation error with GNU++20 option when using complex header (PR #115306)

CHANDRA GHALE via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 10 23:51:57 PST 2024


https://github.com/chandraghale updated https://github.com/llvm/llvm-project/pull/115306

>From 792ccf7ef364f3119b920121dd68285eb4ca1e41 Mon Sep 17 00:00:00 2001
From: Chandra Ghale <ghale at pe31.hpc.amslabs.hpecorp.net>
Date: Thu, 7 Nov 2024 05:54:48 -0600
Subject: [PATCH] Fix for OpenMP offloading compilation with GNU++20 option
 when using complex header

---
 clang/lib/Headers/openmp_wrappers/complex_cmath.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Headers/openmp_wrappers/complex_cmath.h b/clang/lib/Headers/openmp_wrappers/complex_cmath.h
index e3d9aebbbc2436..cee36bde3f522e 100644
--- a/clang/lib/Headers/openmp_wrappers/complex_cmath.h
+++ b/clang/lib/Headers/openmp_wrappers/complex_cmath.h
@@ -64,8 +64,13 @@ template <class _Tp> __DEVICE__ _Tp norm(const std::complex<_Tp> &__c) {
 }
 
 // conj
-
-template <class _Tp> std::complex<_Tp> conj(const std::complex<_Tp> &__c) {
+#ifdef _GLIBCXX20_CONSTEXPR
+#define CXX20_CONSTEXPR_DEVICE __DEVICE__
+#else
+#define CXX20_CONSTEXPR_DEVICE
+#endif
+template <class _Tp>
+CXX20_CONSTEXPR_DEVICE std::complex<_Tp> conj(const std::complex<_Tp> &__c) {
   return std::complex<_Tp>(__c.real(), -__c.imag());
 }
 



More information about the cfe-commits mailing list