Skip to content
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

[libc][complex] fix compiler support matrix for cfloat128 #122593

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Sh0g0-1758
Copy link
Member

@Sh0g0-1758 Sh0g0-1758 commented Jan 11, 2025

Before this patch, godbolt failed to compile cfloat128 with -ffreestanding but with the patch, the compilation succeeds, godbolt.

Fixes: #122500

cc: @nickdesaulniers

@llvmbot llvmbot added the libc label Jan 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 11, 2025

@llvm/pr-subscribers-libc

Author: Shourya Goel (Sh0g0-1758)

Changes

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

1 Files Affected:

  • (modified) libc/include/llvm-libc-types/cfloat128.h (+5-3)
diff --git a/libc/include/llvm-libc-types/cfloat128.h b/libc/include/llvm-libc-types/cfloat128.h
index f76a0c1c2f5af5..1a84cdf9de8d66 100644
--- a/libc/include/llvm-libc-types/cfloat128.h
+++ b/libc/include/llvm-libc-types/cfloat128.h
@@ -18,15 +18,17 @@
 //
 // TODO: Update the complex variant of C23 `_Float128` type detection again when
 // clang supports it.
-#if defined(__STDC_IEC_60559_COMPLEX__) && !defined(__clang__)
-#if !defined(__cplusplus)
+#if !defined(__clang__)
+#if defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)
+#if defined(__GNUC__) && !defined(__cplusplus)
 #define LIBC_TYPES_HAS_CFLOAT128
 typedef _Complex _Float128 cfloat128;
 #elif defined(__GNUC__) && __GNUC__ >= 13
 #define LIBC_TYPES_HAS_CFLOAT128
 typedef _Complex _Float128 cfloat128;
 #endif
-#elif __clang_major__ >= 11 &&                                                 \
+#endif
+#elif (__clang_major__ >= 11) &&                                               \
     (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
 // Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
 // macro to notify the availability of __float128 type:

@Sh0g0-1758 Sh0g0-1758 self-assigned this Jan 11, 2025
Copy link

github-actions bot commented Jan 11, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc] gcc errors related to complex floats
3 participants