Skip to content

Commit b861539

Browse files
authored
[libc][complex] fix compiler support matrix for cfloat128 (#122593)
Before this patch, [godbolt](https://godbolt.org/z/6PPsvv9qd) failed to compile `cfloat128` with `-ffreestanding` but with the patch, the compilation succeeds, [godbolt](https://godbolt.org/z/4M8zzejss). Fixes: #122500 cc: @nickdesaulniers
1 parent f431f93 commit b861539

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

libc/include/llvm-libc-types/cfloat128.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@
1818
//
1919
// TODO: Update the complex variant of C23 `_Float128` type detection again when
2020
// clang supports it.
21-
#if defined(__STDC_IEC_60559_COMPLEX__) && !defined(__clang__)
22-
#if !defined(__cplusplus)
23-
#define LIBC_TYPES_HAS_CFLOAT128
24-
typedef _Complex _Float128 cfloat128;
25-
#elif defined(__GNUC__) && __GNUC__ >= 13
26-
#define LIBC_TYPES_HAS_CFLOAT128
27-
typedef _Complex _Float128 cfloat128;
28-
#endif
29-
#elif __clang_major__ >= 11 && \
21+
#ifdef __clang__
22+
#if (__clang_major__ >= 11) && \
3023
(defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
3124
// Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
3225
// macro to notify the availability of __float128 type:
3326
// https://reviews.llvm.org/D15120
3427
#define LIBC_TYPES_HAS_CFLOAT128
3528
typedef _Complex __float128 cfloat128;
36-
#elif (LDBL_MANT_DIG == 113)
29+
#endif
30+
#elif defined(__GNUC__)
31+
#if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
32+
(__GNUC__ >= 13 || (!defined(__cplusplus)))
33+
#define LIBC_TYPES_HAS_CFLOAT128
34+
typedef _Complex _Float128 cfloat128;
35+
#endif
36+
#endif
37+
38+
#if !defined(LIBC_TYPES_HAS_CFLOAT128) && (LDBL_MANT_DIG == 113)
3739
#define LIBC_TYPES_HAS_CFLOAT128
3840
#define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
3941
typedef _Complex long double cfloat128;

0 commit comments

Comments
 (0)