[Mlir-commits] [mlir] [openmp] [llvm] [clang] [libcxx] [libc] [lldb] [clang-tools-extra] [lld] [libunwind] [flang] [polly] [libcxxabi] [compiler-rt] [libc++][numeric] P0543R3: Saturation arithmetic (PR #77967)
Mark de Wever
llvmlistbot at llvm.org
Sun Jan 21 06:10:24 PST 2024
================
@@ -0,0 +1,172 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+// The test uses "Placeholder variables with no name"
+// UNSUPPORTED: clang-17
+// XFAIL: apple-clang
+
+// <numeric>
+
+// template<class T>
+// constexpr T add_sat(T x, T y) noexcept; // freestanding
+
+#include <cassert>
+#include <concepts>
+#include <limits>
+#include <numeric>
+
+#include "test_macros.h"
+
+template <typename IntegerT>
+constexpr bool test_signed() {
+ constexpr auto minVal = std::numeric_limits<IntegerT>::min();
+ constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
+
+ std::same_as<IntegerT> decltype(auto) _ = std::add_sat(minVal, maxVal);
+ static_assert(noexcept(std::add_sat(minVal, maxVal)));
+
+ // clang-format off
+
+ // Limit values (-1, 0, 1, min, max)
----------------
mordante wrote:
Thanks, this makes validating what the test does a lot easier.
https://github.com/llvm/llvm-project/pull/77967
More information about the Mlir-commits
mailing list