diff options
author | OverMighty <its.overmighty@gmail.com> | 2024-06-28 00:05:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-27 15:05:43 -0700 |
commit | 7a03666401342e71995f8e221a8755eb69187876 (patch) | |
tree | 55d48d34f4ddb560bd0d8f18e7664bcb1dea0adb /libc/src | |
parent | f906e3dd62b979814658e8610388117dd7db7bbf (diff) | |
download | llvm-7a03666401342e71995f8e221a8755eb69187876.zip llvm-7a03666401342e71995f8e221a8755eb69187876.tar.gz llvm-7a03666401342e71995f8e221a8755eb69187876.tar.bz2 |
[libc] Fix compilation errors that occur when building with GCC (#96976)
Diffstat (limited to 'libc/src')
-rw-r--r-- | libc/src/__support/FPUtil/NearestIntegerOperations.h | 3 | ||||
-rw-r--r-- | libc/src/__support/FPUtil/dyadic_float.h | 2 | ||||
-rw-r--r-- | libc/src/__support/FPUtil/generic/FMA.h | 2 | ||||
-rw-r--r-- | libc/src/__support/FPUtil/generic/div.h | 7 | ||||
-rw-r--r-- | libc/src/__support/big_int.h | 5 |
5 files changed, 10 insertions, 9 deletions
diff --git a/libc/src/__support/FPUtil/NearestIntegerOperations.h b/libc/src/__support/FPUtil/NearestIntegerOperations.h index 741e24a..cff3293 100644 --- a/libc/src/__support/FPUtil/NearestIntegerOperations.h +++ b/libc/src/__support/FPUtil/NearestIntegerOperations.h @@ -199,7 +199,8 @@ round_using_specific_rounding_mode(T x, int rnd) { return x; StorageType trim_value = - bits.get_mantissa() & ((StorageType(1) << trim_size) - 1); + bits.get_mantissa() & + static_cast<StorageType>(((StorageType(1) << trim_size) - 1)); StorageType half_value = static_cast<StorageType>((StorageType(1) << (trim_size - 1))); // If exponent is 0, trimSize will be equal to the mantissa width, and diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h index fb1b224..8d44a98 100644 --- a/libc/src/__support/FPUtil/dyadic_float.h +++ b/libc/src/__support/FPUtil/dyadic_float.h @@ -110,7 +110,7 @@ template <size_t Bits> struct DyadicFloat { .get_val(); // volatile prevents constant propagation that would result in infinity // always being returned no matter the current rounding mode. - volatile T two(2.0); + volatile T two = static_cast<T>(2.0); T r = two * d_hi; // TODO: Whether rounding down the absolute value to max_normal should diff --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h index d0a01c3..72341a1 100644 --- a/libc/src/__support/FPUtil/generic/FMA.h +++ b/libc/src/__support/FPUtil/generic/FMA.h @@ -266,7 +266,7 @@ fma(InType x, InType y, InType z) { } DyadicFloat result(prod_sign, prod_lsb_exp - InFPBits::EXP_BIAS, prod_mant); - result.mantissa |= sticky_bits; + result.mantissa |= static_cast<unsigned int>(sticky_bits); return result.template as<OutType, /*ShouldSignalExceptions=*/true>(); } diff --git a/libc/src/__support/FPUtil/generic/div.h b/libc/src/__support/FPUtil/generic/div.h index 843d570..0d84aa8 100644 --- a/libc/src/__support/FPUtil/generic/div.h +++ b/libc/src/__support/FPUtil/generic/div.h @@ -97,14 +97,14 @@ div(InType x, InType y) { // Number of iterations = full output precision + 1 rounding bit + 1 potential // leading 0. - constexpr size_t NUM_ITERS = OutFPBits::FRACTION_LEN + 3; + constexpr int NUM_ITERS = OutFPBits::FRACTION_LEN + 3; int result_exp = xd.exponent - yd.exponent - (NUM_ITERS - 1); InStorageType q = 0; InStorageType r = static_cast<InStorageType>(xd.mantissa >> 2); InStorageType yd_mant_in = static_cast<InStorageType>(yd.mantissa >> 1); - for (size_t i = 0; i < NUM_ITERS; ++i) { + for (int i = 0; i < NUM_ITERS; ++i) { q <<= 1; r <<= 1; if (r >= yd_mant_in) { @@ -114,8 +114,7 @@ div(InType x, InType y) { } DyadicFloat result(result_sign, result_exp, q); - result.mantissa += r != 0; - + result.mantissa |= static_cast<unsigned int>(r != 0); return result.template as<OutType, /*ShouldSignalExceptions=*/true>(); } diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h index 5ce9541..59a3912 100644 --- a/libc/src/__support/big_int.h +++ b/libc/src/__support/big_int.h @@ -387,7 +387,8 @@ public: } // Initialize the first word to |v| and the rest to 0. - template <typename T, typename = cpp::enable_if_t<cpp::is_integral_v<T>>> + template <typename T, typename = cpp::enable_if_t<cpp::is_integral_v<T> && + !cpp::is_same_v<T, bool>>> LIBC_INLINE constexpr BigInt(T v) { constexpr size_t T_SIZE = sizeof(T) * CHAR_BIT; const bool is_neg = Signed && (v < 0); @@ -440,7 +441,7 @@ public: constexpr size_t MAX_COUNT = T_SIZE > Bits ? WORD_COUNT : T_SIZE / WORD_SIZE; for (size_t i = 1; i < MAX_COUNT; ++i) - lo += static_cast<T>(val[i]) << (WORD_SIZE * i); + lo += static_cast<T>(static_cast<T>(val[i]) << (WORD_SIZE * i)); if constexpr (Signed && (T_SIZE > Bits)) { // Extend sign for negative numbers. constexpr T MASK = (~T(0) << Bits); |