llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: None (chandraghale)

<details>
<summary>Changes</summary>

The change done is to fix this issue 
[https://github.com/llvm/llvm-project/issues/113207](url) . Detail discussion 
available in link provided. 

When using the -std=c++20 flag with -fopenmp for OpenMP offloading results in 
the following compilation error. 

Reduced test Case :
```
&gt; cat foo.cpp
#include &lt;complex&gt;

void foo(){
}
&gt; CC -fopenmp -std=gnu++20 -fopenmp-targets=amdgcn-amd-amdhsa 
-Xopenmp-target=amdgcn-amd-amdhsa -march=gfx90a foo.cpp -c
In file included from foo.cpp:1:
In file included from 
/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/lib/clang/18/include/openmp_wrappers/complex:51:
/opt/cray/pe/cce/18.0.1/cce-clang/x86_64/lib/clang/18/include/openmp_wrappers/complex_cmath.h:68:40:
 error: non-constexpr declaration of 'conj' follows constexpr declaration
   68 | template &lt;class _Tp&gt; std::complex&lt;_Tp&gt; conj(const 
std::complex&lt;_Tp&gt; &amp;__c) {
      |                                        ^
/usr/lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/complex:970:5: 
note: previous declaration is here
  970 |     conj(const complex&lt;_Tp&gt;&amp; __z)
      |     ^
1 error generated.
```



---
Full diff: https://github.com/llvm/llvm-project/pull/115306.diff


1 Files Affected:

- (modified) clang/lib/Headers/openmp_wrappers/complex_cmath.h (+7-2) 


``````````diff
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());
 }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/115306
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to