From 4c05998f65a0b3e926e4d94a10656863734e91ae Mon Sep 17 00:00:00 2001 From: Tue Ly Date: Fri, 19 Sep 2025 16:18:20 +0000 Subject: [PATCH] [libc] Update floating testing infra for MSVC compatibility. --- libc/test/UnitTest/FEnvSafeTest.cpp | 3 ++- libc/test/UnitTest/FPMatcher.h | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libc/test/UnitTest/FEnvSafeTest.cpp b/libc/test/UnitTest/FEnvSafeTest.cpp index f644569695eec..2730de350b39a 100644 --- a/libc/test/UnitTest/FEnvSafeTest.cpp +++ b/libc/test/UnitTest/FEnvSafeTest.cpp @@ -51,7 +51,8 @@ void FEnvSafeTest::expect_fenv_eq(const fenv_t &before_fenv, EXPECT_EQ(before_state.ControlWord, after_state.ControlWord); EXPECT_EQ(before_state.StatusWord, after_state.StatusWord); -#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__) +#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__) && \ + !defined(LIBC_COMPILER_IS_MSVC) using LIBC_NAMESPACE::fputil::internal::FPState; const FPState &before_state = reinterpret_cast(before_fenv); const FPState &after_state = reinterpret_cast(after_fenv); diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h index 6a68211e6d849..f74276f54eb25 100644 --- a/libc/test/UnitTest/FPMatcher.h +++ b/libc/test/UnitTest/FPMatcher.h @@ -125,6 +125,7 @@ template class CFPMatcher : public Matcher { bool match(T actualValue) { actual = actualValue; +#ifndef LIBC_COMPILER_IS_MSVC if constexpr (cpp::is_complex_type_same()) return matchComplex(); else if constexpr (cpp::is_complex_type_same()) @@ -134,14 +135,18 @@ template class CFPMatcher : public Matcher { #ifdef LIBC_TYPES_HAS_CFLOAT16 else if constexpr (cpp::is_complex_type_same()) return matchComplex(); -#endif +#endif // LIBC_TYPES_HAS_CFLOAT16 #ifdef LIBC_TYPES_HAS_CFLOAT128 else if constexpr (cpp::is_complex_type_same()) return matchComplex(); -#endif +#endif // LIBC_TYPES_HAS_CFLOAT128 +#else // LIBC_COMPILER_IS_MSVC + return true; +#endif // LIBC_COMPILER_IS_MSVC } void explainError() override { +#ifndef LIBC_COMPILER_IS_MSVC if constexpr (cpp::is_complex_type_same()) return explainErrorComplex(); else if constexpr (cpp::is_complex_type_same()) @@ -151,11 +156,12 @@ template class CFPMatcher : public Matcher { #ifdef LIBC_TYPES_HAS_CFLOAT16 else if constexpr (cpp::is_complex_type_same()) return explainErrorComplex(); -#endif +#endif // LIBC_TYPES_HAS_CFLOAT16 #ifdef LIBC_TYPES_HAS_CFLOAT128 else if constexpr (cpp::is_complex_type_same()) return explainErrorComplex(); -#endif +#endif // LIBC_TYPES_HAS_CFLOAT128 +#endif // LIBC_COMPILER_IS_MSVC } };