[flang-commits] [flang] [llvm] [Flang] Introduce common::numeric_limits (PR #228108)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Wed Oct 14 08:47:22 PDT 2026


================
@@ -113,6 +114,37 @@ static void TestVsNative() {
 }
 #endif
 
+/// T is the native __(u)int128_t implementation to compare against. It only
+/// executes on platforms with HAS_NATIVE_UINT128_T enabled.
+template <typename T> static void TestNumericLimitsVsNative() {
+  using Std = std::numeric_limits<T>;
+  using Detail = Fortran::common::detail::numeric_limits<T>;
+  using Common = Fortran::common::numeric_limits<T>;
+
+  // Our implementation in Detail must be equivalent to Std
+  // (if Std supports __(u)int128).
+  if constexpr (Std::is_specialized) {
+    TEST(Detail::is_specialized == Std::is_specialized);
+    TEST(Detail::is_signed == Std::is_signed);
+    TEST(Detail::is_integer == Std::is_integer);
+    TEST(Detail::min() == Std::min());
+    TEST(Detail::max() == Std::max());
+    TEST(Detail::lowest() == Std::lowest());
+  } else {
+    llvm::outs() << "common::numeric_limits is not specialized for this type\n";
----------------
Meinersbur wrote:

Another search/replace slip

https://github.com/llvm/llvm-project/pull/228108


More information about the flang-commits mailing list