Skip to content

[flang] Fixed build issues after f20ea05. #84377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

vzakhari
Copy link
Contributor

@vzakhari vzakhari commented Mar 7, 2024

Older versions of clang do not have __builtin_complex, but they
may define __GNUC__.

@vzakhari vzakhari requested a review from Renaud-K March 7, 2024 20:39
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Mar 7, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 7, 2024

@llvm/pr-subscribers-flang-runtime

Author: Slava Zakharin (vzakhari)

Changes

Older versions of clang do not have __builtin_complex, but they
may define __GNUC__.


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

1 Files Affected:

  • (modified) flang/runtime/complex-reduction.c (+4-1)
diff --git a/flang/runtime/complex-reduction.c b/flang/runtime/complex-reduction.c
index 72c31ce08b875a..574536badcf6bf 100644
--- a/flang/runtime/complex-reduction.c
+++ b/flang/runtime/complex-reduction.c
@@ -75,6 +75,7 @@ static long_double_Complex_t CMPLXL(long double r, long double i) {
 #endif
 #endif
 
+/* clang-format off */
 #if LDBL_MANT_DIG == 113 || HAS_FLOAT128
 #ifndef CMPLXF128
 /*
@@ -82,7 +83,8 @@ static long_double_Complex_t CMPLXL(long double r, long double i) {
  * supports __builtin_complex. For Clang, require >=12.0.
  * Otherwise, rely on the memory layout compatibility.
  */
-#if (defined(__clang_major__) && (__clang_major__ >= 12)) || defined(__GNUC__)
+#if (defined(__clang_major__) && (__clang_major__ >= 12)) ||
+    (defined(__GNUC__) && !defined(__clang__))
 #define CMPLXF128 __builtin_complex
 #else
 static CFloat128ComplexType CMPLXF128(CFloat128Type r, CFloat128Type i) {
@@ -154,3 +156,4 @@ ADAPT_REDUCTION(DotProductComplex10, long_double_Complex_t,
 ADAPT_REDUCTION(DotProductComplex16, CFloat128ComplexType, CppComplexFloat128,
     CMPLXF128, DOT_PRODUCT_ARGS, DOT_PRODUCT_ARG_NAMES)
 #endif
+    /* clang-format on */

Older versions of clang do not have __builtin_complex, but they
may define `__GNUC__`.
@vzakhari vzakhari force-pushed the flang_gcc_detection branch from 22032ea to 50aff75 Compare March 7, 2024 20:51
Copy link
Contributor

@Renaud-K Renaud-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@vzakhari vzakhari merged commit d9c8550 into llvm:main Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants