Skip to content

Commit d508701

Browse files
authored
[libc][complex] add additonal header guards for CFP16 and CFP128 (#112879)
Fixes build errors due to #112594
1 parent e1330d9 commit d508701

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@
1212
#include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
1313

1414
// Currently, the complex variant of C23 `_Float128` type is only defined as a
15-
// built-in type in GCC 7 or later, and only for C. For C++, or for clang,
16-
// the complex variant of `__float128` is defined instead, and only on x86-64
17-
// targets.
15+
// built-in type in GCC 7 or later, for C and in GCC 13 or later, for C++. For
16+
// clang, the complex variant of `__float128` is defined instead, and only on
17+
// x86-64 targets for clang 11 or later.
1818
//
1919
// TODO: Update the complex variant of C23 `_Float128` type detection again when
2020
// clang supports it.
21-
// https://github.com/llvm/llvm-project/issues/80195
22-
#if defined(__STDC_IEC_60559_COMPLEX__) && !defined(__clang__) && \
23-
!defined(__cplusplus)
21+
#if defined(__STDC_IEC_60559_COMPLEX__) && !defined(__clang__)
22+
#if !defined(__cplusplus)
2423
#define LIBC_TYPES_HAS_CFLOAT128
2524
typedef _Complex _Float128 cfloat128;
26-
#elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
27-
// Use _Complex __float128 type. gcc and clang sometime use __SIZEOF_FLOAT128__
28-
// to notify the availability of __float128. clang also uses __FLOAT128__ macro
29-
// to notify the availability of __float128 type:
25+
#elif defined(__GNUC__) && __GNUC__ >= 13
26+
#define LIBC_TYPES_HAS_CFLOAT128
27+
typedef _Complex _Float128 cfloat128;
28+
#endif
29+
#elif __clang_major__ >= 11 && \
30+
(defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
31+
// Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
32+
// macro to notify the availability of __float128 type:
3033
// https://reviews.llvm.org/D15120
3134
#define LIBC_TYPES_HAS_CFLOAT128
3235
typedef _Complex __float128 cfloat128;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#define LLVM_LIBC_TYPES_CFLOAT16_H
1111

1212
#if defined(__FLT16_MANT_DIG__) && \
13-
(!defined(__GNUC__) || __GNUC__ >= 13 || defined(__clang__)) && \
13+
(!defined(__GNUC__) || __GNUC__ >= 13 || \
14+
(defined(__clang__) && __clang_major__ >= 14)) && \
1415
!defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \
1516
!defined(_WIN32)
1617
#define LIBC_TYPES_HAS_CFLOAT16

0 commit comments

Comments
 (0)