Skip to content

Conversation

@DavidSpickett
Copy link
Collaborator

This removes the need for the long list of platforms in strong_order_long_double_verify.

This removes the need for the long list of platforms in
strong_order_long_double_verify.
@DavidSpickett DavidSpickett requested a review from a team as a code owner August 30, 2024 10:45
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Aug 30, 2024
@DavidSpickett
Copy link
Collaborator Author

Alternative to #103903.

@llvmbot
Copy link
Member

llvmbot commented Aug 30, 2024

@llvm/pr-subscribers-libcxx

Author: David Spickett (DavidSpickett)

Changes

This removes the need for the long list of platforms in strong_order_long_double_verify.


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

3 Files Affected:

  • (modified) libcxx/test/std/language.support/cmp/cmp.alg/strong_order_long_double.verify.cpp (+4-15)
  • (modified) libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp (+1-1)
  • (modified) libcxx/test/support/test_macros.h (+4)
diff --git a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order_long_double.verify.cpp b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order_long_double.verify.cpp
index c9c2ba20021491..cd032d48648953 100644
--- a/libcxx/test/std/language.support/cmp/cmp.alg/strong_order_long_double.verify.cpp
+++ b/libcxx/test/std/language.support/cmp/cmp.alg/strong_order_long_double.verify.cpp
@@ -8,21 +8,6 @@
 
 // UNSUPPORTED: c++03, c++11, c++14, c++17
 
-// The following platforms have sizeof(long double) == sizeof(double), so this test doesn't apply to them.
-// This test does apply to aarch64 where Arm's AAPCS64 is followed. There they are different sizes.
-// XFAIL: target={{arm64|arm64e|armv(7|8)(l|m)?|powerpc|powerpc64}}-{{.+}}
-
-// MSVC configurations have long double equal to regular double on all
-// architectures.
-// XFAIL: target={{.+}}-pc-windows-msvc
-
-// ARM/AArch64 MinGW also has got long double equal to regular double, just
-// like MSVC (thus match both MinGW and MSVC here, for those architectures).
-// XFAIL: target={{aarch64|armv7}}-{{.*}}-windows-{{.+}}
-
-// Android's 32-bit x86 target has long double equal to regular double.
-// XFAIL: target=i686-{{.+}}-android{{.*}}
-
 // <compare>
 
 // template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
@@ -37,5 +22,9 @@
 
 void f() {
     long double ld = 3.14;
+#ifdef TEST_LONG_DOUBLE_IS_DOUBLE
+    (void)ld; // expected-no-diagnostics
+#else
     (void)std::strong_order(ld, ld);  // expected-error@*:* {{std::strong_order is unimplemented for this floating-point type}}
+#endif
 }
diff --git a/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp b/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
index f73877416a7170..044589298439c1 100644
--- a/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
+++ b/libcxx/test/std/numerics/bit/bit.cast/bit_cast.pass.cpp
@@ -229,7 +229,7 @@ bool tests() {
         test_roundtrip_through_nested_T<false>(i);
         test_roundtrip_through_buffer<false>(i);
 
-#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
+#ifdef TEST_LONG_DOUBLE_IS_DOUBLE
         test_roundtrip_through<double, false>(i);
 #endif
 #if defined(__SIZEOF_INT128__) && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_INT128__ &&                                       \
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index 6f7ec3aa0c1f9f..5d4c1a65cfafb2 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -511,4 +511,8 @@ inline Tp const& DoNotOptimize(Tp const& value) {
 #  define TEST_CONSTEXPR_OPERATOR_NEW
 #endif
 
+#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
+#  define TEST_LONG_DOUBLE_IS_DOUBLE
+#endif
+
 #endif // SUPPORT_TEST_MACROS_HPP

@frederick-vs-ja
Copy link
Contributor

Now we can guard these 2 lines with the newly added macro.

// test_1_3<long double>(); // UNIMPLEMENTED
test_1_4();
static_assert(test_1_3<float>());
static_assert(test_1_3<double>());
// static_assert(test_1_3<long double>()); // UNIMPLEMENTED

@DavidSpickett DavidSpickett merged commit c792de2 into llvm:main Aug 30, 2024
@DavidSpickett DavidSpickett deleted the libcxx-ld2 branch August 30, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants