[libcxx-commits] [libcxx] [libc++][numeric][NFC] Cleanup *Saturation arithmetic* tests (PR #101826)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 3 07:30:19 PDT 2024


https://github.com/H-G-Hristov created https://github.com/llvm/llvm-project/pull/101826

This simplifies the tests a little bit:

Fixed -> TODO(LLVM20): remove [[maybe_unused]] and `{}` scope since all supported compilers support "Placeholder variables with no name"

*IMPORTANT: To be merged after CI drop LLVM17 support.*

>From 6e0c6f995fefb61bf9712ed267f252334d4d608f Mon Sep 17 00:00:00 2001
From: Hristo Hristov <hghristov.rmm at gmail.com>
Date: Sat, 3 Aug 2024 17:29:01 +0300
Subject: [PATCH] [libc++][numeric][NFC] Cleanup *Saturation arithmetic* tests

This simplifies the tests a little bit:

Fixed -> TODO(LLVM20): remove [[maybe_unused]] and `{}` scope since all supported compilers support "Placeholder variables with no name"
---
 .../numeric.ops.sat/add_sat.pass.cpp          |   6 +-
 .../numeric.ops.sat/div_sat.pass.cpp          |   6 +-
 .../numeric.ops.sat/mul_sat.pass.cpp          |   6 +-
 .../numeric.ops.sat/saturate_cast.pass.cpp    | 131 +++++++++---------
 .../numeric.ops.sat/sub_sat.pass.cpp          |   6 +-
 5 files changed, 72 insertions(+), 83 deletions(-)

diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/add_sat.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/add_sat.pass.cpp
index 036bf53e36dcd..8288378ab769e 100644
--- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/add_sat.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/add_sat.pass.cpp
@@ -25,8 +25,7 @@ constexpr bool test_signed() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]]  since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::add_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::add_sat(minVal, maxVal);
 
   static_assert(noexcept(std::add_sat(minVal, maxVal)));
 
@@ -97,8 +96,7 @@ constexpr bool test_unsigned() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]]  since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::add_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::add_sat(minVal, maxVal);
 
   static_assert(noexcept(std::add_sat(minVal, maxVal)));
 
diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/div_sat.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/div_sat.pass.cpp
index b1cace74d8828..fa9841b24d27a 100644
--- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/div_sat.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/div_sat.pass.cpp
@@ -26,8 +26,7 @@ constexpr bool test_signed() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]] and `{}` scope since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::div_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::div_sat(minVal, maxVal);
 
   static_assert(noexcept(std::div_sat(minVal, maxVal)));
 
@@ -89,8 +88,7 @@ constexpr bool test_unsigned() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]] since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::div_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::div_sat(minVal, maxVal);
   static_assert(noexcept(std::div_sat(minVal, maxVal)));
 
   // clang-format off
diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/mul_sat.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/mul_sat.pass.cpp
index 2c8eec57e1204..060eb52103a02 100644
--- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/mul_sat.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/mul_sat.pass.cpp
@@ -26,8 +26,7 @@ constexpr bool test_signed() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]] since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::mul_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::mul_sat(minVal, maxVal);
 
   static_assert(noexcept(std::mul_sat(minVal, maxVal)));
 
@@ -103,8 +102,7 @@ constexpr bool test_unsigned() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]] since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::mul_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::mul_sat(minVal, maxVal);
 
   static_assert(noexcept(std::mul_sat(minVal, maxVal)));
 
diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp
index cbca37e3a6613..4ba27d6636894 100644
--- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/saturate_cast.pass.cpp
@@ -20,7 +20,6 @@
 #include <numeric>
 
 #include "test_macros.h"
-#include <print>
 
 // Smaller to larger
 static_assert(noexcept(std::saturate_cast<signed int>(std::numeric_limits<signed char>::max())));
@@ -72,314 +71,312 @@ constexpr bool test() {
 
   // signed char
 
-  // TODO(LLVM-20) remove [[maybe_unused]] and `{}` scope since all supported compilers support "Placeholder variables with no name",
-  // here and below...
-  { [[maybe_unused]] std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(SCHAR_MAX); }
+  std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(SCHAR_MAX);
   assert(std::saturate_cast<signed char>(SCHAR_MIN)  == SCHAR_MIN);
   assert(std::saturate_cast<signed char>(      O_C)  ==       O_C);
   assert(std::saturate_cast<signed char>(SCHAR_MAX)  == SCHAR_MAX);
 
-  { [[maybe_unused]] std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(UCHAR_MAX); }
+  std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(UCHAR_MAX);
   assert(std::saturate_cast<signed char>(     O_UC)  ==       O_C);
   assert(std::saturate_cast<signed char>(UCHAR_MAX)  == SCHAR_MAX);
 
-  { [[maybe_unused]] std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(sBigMax); }
+  std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(sBigMax);
   assert(std::saturate_cast<signed char>(sBigMin)    == SCHAR_MIN); // saturated
   assert(std::saturate_cast<signed char>(  sZero)    ==       O_C);
   assert(std::saturate_cast<signed char>(sBigMax)    == SCHAR_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(uBigMax); }
+  std::same_as<signed char> decltype(auto) _ = std::saturate_cast<signed char>(uBigMax);
   assert(std::saturate_cast<signed char>(  uZero)    ==       O_C);
   assert(std::saturate_cast<signed char>(uBigMax)    == SCHAR_MAX); // saturated
 
   // short
 
-  { [[maybe_unused]] std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(SCHAR_MAX); }
+  std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(SCHAR_MAX);
   assert(std::saturate_cast<signed short int>(SCHAR_MIN) == static_cast<signed short int>(SCHAR_MIN));
   assert(std::saturate_cast<signed short int>(      O_C) == O_S);
   assert(std::saturate_cast<signed short int>(SCHAR_MAX) == static_cast<signed short int>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(UCHAR_MAX); }
+  std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(UCHAR_MAX);
   assert(std::saturate_cast<signed short int>(     O_UC) == O_S);
   assert(std::saturate_cast<signed short int>(UCHAR_MAX) == static_cast<signed short int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(SHRT_MAX); }
+  std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(SHRT_MAX);
   assert(std::saturate_cast<signed short int>( SHRT_MIN) == SHRT_MIN);
   assert(std::saturate_cast<signed short int>(      O_S) == O_S);
   assert(std::saturate_cast<signed short int>( SHRT_MAX) == SHRT_MAX);
 
-  { [[maybe_unused]] std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(USHRT_MAX); }
+  std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(USHRT_MAX);
   assert(std::saturate_cast<signed short int>(     O_US) == O_S);
   assert(std::saturate_cast<signed short int>(USHRT_MAX) == SHRT_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(sBigMax); }
+  std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(sBigMax);
   assert(std::saturate_cast<signed short int>( sBigMin)   == SHRT_MIN); // saturated
   assert(std::saturate_cast<signed short int>(   sZero)   == O_S);
   assert(std::saturate_cast<signed short int>( sBigMax)   == SHRT_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(uBigMax); }
+  std::same_as<signed short int> decltype(auto) _ = std::saturate_cast<signed short int>(uBigMax);
   assert(std::saturate_cast<signed short int>(   uZero)   == O_S);
   assert(std::saturate_cast<signed short int>( uBigMax)   == SHRT_MAX); // saturated
 
   // int
 
-  { [[maybe_unused]] std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(SCHAR_MAX); }
+  std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(SCHAR_MAX);
   assert(std::saturate_cast<signed int>(SCHAR_MIN) == static_cast<signed int>(SCHAR_MIN));
   assert(std::saturate_cast<signed int>(      O_C) == 0);
   assert(std::saturate_cast<signed int>(SCHAR_MAX) == static_cast<signed int>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(UCHAR_MAX); }
+  std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(UCHAR_MAX);
   assert(std::saturate_cast<signed int>(     O_UC) == 0);
   assert(std::saturate_cast<signed int>(UCHAR_MAX) == static_cast<signed int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(INT_MAX); }
+  std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(INT_MAX);
   assert(std::saturate_cast<signed int>(  INT_MIN) == INT_MIN);
   assert(std::saturate_cast<signed int>(        0) == 0);
   assert(std::saturate_cast<signed int>(  INT_MAX) == INT_MAX);
 
-  { [[maybe_unused]] std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(UINT_MAX); }
+  std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(UINT_MAX);
   assert(std::saturate_cast<signed int>(       0)  == 0);
   assert(std::saturate_cast<signed int>(UINT_MAX)  == INT_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(sBigMax); }
+  std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(sBigMax);
   assert(std::saturate_cast<signed int>( sBigMin)  == INT_MIN); // saturated
   assert(std::saturate_cast<signed int>(   sZero)  == 0);
   assert(std::saturate_cast<signed int>( sBigMax)  == INT_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(uBigMax); }
+  std::same_as<signed int> decltype(auto) _ = std::saturate_cast<signed int>(uBigMax);
   assert(std::saturate_cast<signed int>( uZero)    == 0);
   assert(std::saturate_cast<signed int>( uBigMax)  == INT_MAX); // saturated
 
   // long
 
-  { [[maybe_unused]] std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(SCHAR_MAX); }
+  std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(SCHAR_MAX);
   assert(std::saturate_cast<signed long int>(SCHAR_MIN) == static_cast<signed long int>(SCHAR_MIN));
   assert(std::saturate_cast<signed long int>(      O_C) == 0L);
   assert(std::saturate_cast<signed long int>(SCHAR_MAX) == static_cast<signed long int>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(UCHAR_MAX); }
+  std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(UCHAR_MAX);
   assert(std::saturate_cast<signed long int>(     O_UC) == 0L);
   assert(std::saturate_cast<signed long int>(UCHAR_MAX) == static_cast<signed long int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(LONG_MAX); }
+  std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(LONG_MAX);
   assert(std::saturate_cast<signed long int>( LONG_MIN) == LONG_MIN);
   assert(std::saturate_cast<signed long int>(       0L) == 0L);
   assert(std::saturate_cast<signed long int>( LONG_MAX) == LONG_MAX);
 
-  { [[maybe_unused]] std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(ULONG_MAX); }
+  std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(ULONG_MAX);
   assert(std::saturate_cast<signed long int>(      0UL) == 0L);
   assert(std::saturate_cast<signed long int>(ULONG_MAX) == LONG_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(sBigMax); }
+  std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(sBigMax);
   assert(std::saturate_cast<signed long int>(  sBigMin) == LONG_MIN); // saturated
   assert(std::saturate_cast<signed long int>(    sZero) == 0L);
   assert(std::saturate_cast<signed long int>(  sBigMax) == LONG_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(uBigMax); }
+  std::same_as<signed long int> decltype(auto) _ = std::saturate_cast<signed long int>(uBigMax);
   assert(std::saturate_cast<signed long int>(    uZero) == 0L);
   assert(std::saturate_cast<signed long int>(  uBigMax) == LONG_MAX); // saturated
 
   // long long
 
-  { [[maybe_unused]] std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(SCHAR_MAX); }
+  std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(SCHAR_MAX);
   assert(std::saturate_cast<signed long long int>(SCHAR_MIN) == static_cast<signed long long int>(SCHAR_MIN));
   assert(std::saturate_cast<signed long long int>(      0LL) == 0LL);
   assert(std::saturate_cast<signed long long int>(SCHAR_MAX) == static_cast<signed long long int>(SCHAR_MAX));
 
-  { [[maybe_unused]]   std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(UCHAR_MAX); }
+    std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(UCHAR_MAX);
   assert(std::saturate_cast<signed long long int>(     O_UC) == 0LL);
   assert(std::saturate_cast<signed long long int>(UCHAR_MAX) == static_cast<signed long long int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(LLONG_MIN); }
+  std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(LLONG_MIN);
   assert(std::saturate_cast<signed long long int>(LLONG_MIN) == LLONG_MIN);
   assert(std::saturate_cast<signed long long int>(      0LL) == 0LL);
   assert(std::saturate_cast<signed long long int>(LLONG_MAX) == LLONG_MAX);
 
-  { [[maybe_unused]] std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(ULLONG_MAX); }
+  std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(ULLONG_MAX);
   assert(std::saturate_cast<signed long long int>(      0ULL) == 0LL);
   assert(std::saturate_cast<signed long long int>(ULLONG_MAX) == LLONG_MAX); // saturated
 
 #ifndef TEST_HAS_NO_INT128
-  { [[maybe_unused]] std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(sBigMax); }
+  std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(sBigMax);
   assert(std::saturate_cast<signed long long int>(   sBigMin) == LLONG_MIN); // (128-bit) saturated
   assert(std::saturate_cast<signed long long int>(     sZero) == 0LL);
   assert(std::saturate_cast<signed long long int>(   sBigMax) == LLONG_MAX); // (128-bit) saturated
 
-  { [[maybe_unused]] std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(uBigMax); }
+  std::same_as<signed long long int> decltype(auto) _ = std::saturate_cast<signed long long int>(uBigMax);
   assert(std::saturate_cast<signed long long int>(     uZero) == 0LL);
   assert(std::saturate_cast<signed long long int>(   uBigMax) == LLONG_MAX); // (128-bit) saturated
 
-  { [[maybe_unused]] std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(SCHAR_MAX); }
+  std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(SCHAR_MAX);
   assert(std::saturate_cast<__int128_t>(SCHAR_MIN) == static_cast<__int128_t>(SCHAR_MIN));
   assert(std::saturate_cast<__int128_t>(      O_C) == sZero);
   assert(std::saturate_cast<__int128_t>(SCHAR_MAX) == static_cast<__int128_t>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(UCHAR_MAX); }
+  std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(UCHAR_MAX);
   assert(std::saturate_cast<__int128_t>(     O_UC) == sZero);
   assert(std::saturate_cast<__int128_t>(UCHAR_MAX) == static_cast<__int128_t>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(sBigMax); }
+  std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(sBigMax);
   assert(std::saturate_cast<__int128_t>(  sBigMin) == sBigMin);
   assert(std::saturate_cast<__int128_t>(    sZero) == sZero);
   assert(std::saturate_cast<__int128_t>(  sBigMax) == sBigMax);
 
-  { [[maybe_unused]] std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(uBigMax); }
+  std::same_as<__int128_t> decltype(auto) _ = std::saturate_cast<__int128_t>(uBigMax);
   assert(std::saturate_cast<__int128_t>(    uZero) == sZero);
   assert(std::saturate_cast<__int128_t>(  uBigMax) == sBigMax); // saturated
 #endif
 
   // unsigned char
 
-  { [[maybe_unused]] std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(SCHAR_MAX); }
+  std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(SCHAR_MAX);
   assert(std::saturate_cast<unsigned char>(SCHAR_MIN) == O_UC);
   assert(std::saturate_cast<unsigned char>(      O_C) == O_UC);
   assert(std::saturate_cast<unsigned char>(SCHAR_MAX) == static_cast<unsigned char>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(UCHAR_MAX); }
+  std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(UCHAR_MAX);
   assert(std::saturate_cast<unsigned char>(     O_UC) == O_UC);
   assert(std::saturate_cast<unsigned char>(UCHAR_MAX) == UCHAR_MAX);
 
-  { [[maybe_unused]] std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(sBigMax); }
+  std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(sBigMax);
   assert(std::saturate_cast<unsigned char>(  sBigMin) == O_UC);      // saturated
   assert(std::saturate_cast<unsigned char>(    sZero) == O_UC);
   assert(std::saturate_cast<unsigned char>(  sBigMax) == UCHAR_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(uBigMax); }
+  std::same_as<unsigned char> decltype(auto) _ = std::saturate_cast<unsigned char>(uBigMax);
   assert(std::saturate_cast<unsigned char>(    uZero) == O_UC);
   assert(std::saturate_cast<unsigned char>(  uBigMax) == UCHAR_MAX); // saturated
 
   // unsigned short
 
-  { [[maybe_unused]] std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(SCHAR_MAX); }
+  std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(SCHAR_MAX);
   assert(std::saturate_cast<unsigned short int>(SCHAR_MIN) == O_US);
   assert(std::saturate_cast<unsigned short int>(      O_C) == O_US);
   assert(std::saturate_cast<unsigned short int>(SCHAR_MAX) == static_cast<unsigned short int>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(UCHAR_MAX); }
+  std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(UCHAR_MAX);
   assert(std::saturate_cast<unsigned short int>(     O_UC) == O_US);
   assert(std::saturate_cast<unsigned short int>(UCHAR_MAX) == static_cast<unsigned short int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(SCHAR_MIN); }
+  std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(SCHAR_MIN);
   assert(std::saturate_cast<unsigned short int>( SHRT_MIN) == O_US);
   assert(std::saturate_cast<unsigned short int>(      O_S) == O_US);
   assert(std::saturate_cast<unsigned short int>( SHRT_MAX) == static_cast<unsigned short int>(SHRT_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(UCHAR_MAX); }
+  std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(UCHAR_MAX);
   assert(std::saturate_cast<unsigned short int>(     O_US) == O_US);
   assert(std::saturate_cast<unsigned short int>(USHRT_MAX) == USHRT_MAX);
 
-  { [[maybe_unused]] std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(sBigMax); }
+  std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(sBigMax);
   assert(std::saturate_cast<unsigned short int>(  sBigMin) == O_US);      // saturated
   assert(std::saturate_cast<unsigned short int>(    sZero) == O_US);
   assert(std::saturate_cast<unsigned short int>(  sBigMax) == USHRT_MAX); // saturated
 
-  { [[maybe_unused]] std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(uBigMax); }
+  std::same_as<unsigned short int> decltype(auto) _ = std::saturate_cast<unsigned short int>(uBigMax);
   assert(std::saturate_cast<unsigned short int>(    uZero) == O_US);
   assert(std::saturate_cast<unsigned short int>(  uBigMax) == USHRT_MAX); // saturated
 
   // unsigned int
 
-  { [[maybe_unused]] std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(SCHAR_MAX); }
+  std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(SCHAR_MAX);
   assert(std::saturate_cast<unsigned int>(SCHAR_MIN) == O_US);
   assert(std::saturate_cast<unsigned int>(     O_UC) == 0U);
   assert(std::saturate_cast<unsigned int>(SCHAR_MAX) == static_cast<unsigned int>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(UCHAR_MAX); }
+  std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(UCHAR_MAX);
   assert(std::saturate_cast<unsigned int>(     O_UC) == 0U);
   assert(std::saturate_cast<unsigned int>(UCHAR_MAX) == static_cast<unsigned int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(INT_MAX); }
+  std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(INT_MAX);
   assert(std::saturate_cast<unsigned int>(  INT_MIN) == 0U);
   assert(std::saturate_cast<unsigned int>(        0) == 0U);
   assert(std::saturate_cast<unsigned int>(  INT_MAX) == static_cast<unsigned int>(INT_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(UINT_MAX); }
+  std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(UINT_MAX);
   assert(std::saturate_cast<unsigned int>(       0U) == 0U);
   assert(std::saturate_cast<unsigned int>( UINT_MAX) == UINT_MAX);
 
-  { [[maybe_unused]] std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(sBigMax); }
+  std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(sBigMax);
   assert(std::saturate_cast<unsigned int>(  sBigMin) == 0U);       // saturated
   assert(std::saturate_cast<unsigned int>(    sZero) == 0U);
   assert(std::saturate_cast<unsigned int>(  sBigMax) == UINT_MAX); // saturated
   
-  { [[maybe_unused]] std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(uBigMax); }
+  std::same_as<unsigned int> decltype(auto) _ = std::saturate_cast<unsigned int>(uBigMax);
   assert(std::saturate_cast<unsigned int>(    uZero) == 0U);
   assert(std::saturate_cast<unsigned int>(  uBigMax) == UINT_MAX);  // saturated
 
   // unsigned long
 
-  { [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(SCHAR_MAX); }
+  std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(SCHAR_MAX);
   assert(std::saturate_cast<unsigned long int>(SCHAR_MIN) == 0UL);
   assert(std::saturate_cast<unsigned long int>(      O_C) == 0UL);
   assert(std::saturate_cast<unsigned long int>(SCHAR_MAX) == static_cast<unsigned long int>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(UCHAR_MAX); }
+  std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(UCHAR_MAX);
   assert(std::saturate_cast<unsigned long int>(     O_UC) == 0UL);
   assert(std::saturate_cast<unsigned long int>(UCHAR_MAX) == static_cast<unsigned long int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(LONG_MAX); }
+  std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(LONG_MAX);
   assert(std::saturate_cast<unsigned long int>( LONG_MIN) == 0UL);
   assert(std::saturate_cast<unsigned long int>(       0L) == 0UL);
   assert(std::saturate_cast<unsigned long int>( LONG_MAX) == static_cast<unsigned long int>(LONG_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(ULONG_MAX); }
+  std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(ULONG_MAX);
   assert(std::saturate_cast<unsigned long int>(      0UL) == 0UL);
   assert(std::saturate_cast<unsigned long int>(ULONG_MAX) == ULONG_MAX);
 
-  { [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(sBigMax); }
+  std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(sBigMax);
   assert(std::saturate_cast<unsigned long int>(  sBigMin) == 0UL);       // saturated
   assert(std::saturate_cast<unsigned long int>(    sZero) == 0UL);
   assert(std::saturate_cast<unsigned long int>(  sBigMax) == (sizeof(UIntT) > sizeof(unsigned long int) ? ULONG_MAX : LONG_MAX)); // saturated depending on underlying types
 
-  { [[maybe_unused]] std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(uBigMax); }
+  std::same_as<unsigned long int> decltype(auto) _ = std::saturate_cast<unsigned long int>(uBigMax);
   assert(std::saturate_cast<unsigned long int>(    uZero) == 0UL);
   assert(std::saturate_cast<unsigned long int>(  uBigMax) == ULONG_MAX); // saturated
 
   // unsigned long long
 
-  { [[maybe_unused]] std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(SCHAR_MAX); }
+  std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(SCHAR_MAX);
   assert(std::saturate_cast<unsigned long long int>( SCHAR_MIN) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>(       O_C) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>( SCHAR_MAX) == static_cast<unsigned long long int>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned long long  int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(UCHAR_MAX); }
+  std::same_as<unsigned long long  int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(UCHAR_MAX);
   assert(std::saturate_cast<unsigned long long int>(      O_UC) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>( UCHAR_MAX) == static_cast<unsigned long long int>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(LLONG_MAX); }
+  std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(LLONG_MAX);
   assert(std::saturate_cast<unsigned long long int>( LLONG_MIN) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>(       0LL) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>( LLONG_MAX) == static_cast<unsigned long long int>(LLONG_MAX));
 
-  { [[maybe_unused]] std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(ULLONG_MAX); }
+  std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(ULLONG_MAX);
   assert(std::saturate_cast<unsigned long long int>(      0ULL) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>(ULLONG_MAX) == ULLONG_MAX);
 
 #ifndef TEST_HAS_NO_INT128
-  { [[maybe_unused]] std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(sBigMax); }
+  std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(sBigMax);
   assert(std::saturate_cast<unsigned long long int>(   sBigMin) == 0ULL);       // (128-bit) saturated
   assert(std::saturate_cast<unsigned long long int>(     sZero) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>(   sBigMax) == ULLONG_MAX); // (128-bit) saturated
 
-  { [[maybe_unused]] std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(uBigMax); }
+  std::same_as<unsigned long long int> decltype(auto) _ = std::saturate_cast<unsigned long long int>(uBigMax);
   assert(std::saturate_cast<unsigned long long int>(     uZero) == 0ULL);
   assert(std::saturate_cast<unsigned long long int>(   uBigMax) == ULLONG_MAX); // (128-bit) saturated
 
-  { [[maybe_unused]] std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(SCHAR_MIN); }
+  std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(SCHAR_MIN);
   assert(std::saturate_cast<__uint128_t>(SCHAR_MIN) == uZero);
   assert(std::saturate_cast<__uint128_t>(      O_C) == uZero);
   assert(std::saturate_cast<__uint128_t>(SCHAR_MAX) == static_cast<__uint128_t>(SCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(UCHAR_MAX); }
+  std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(UCHAR_MAX);
   assert(std::saturate_cast<__uint128_t>(     O_UC) == uZero);
   assert(std::saturate_cast<__uint128_t>(UCHAR_MAX) == static_cast<__uint128_t>(UCHAR_MAX));
 
-  { [[maybe_unused]] std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(sBigMax); }
+  std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(sBigMax);
   assert(std::saturate_cast<__uint128_t>(  sBigMin) == uZero); // saturated
   assert(std::saturate_cast<__uint128_t>(    sZero) == uZero);
   assert(std::saturate_cast<__uint128_t>(  sBigMax) == static_cast<__uint128_t>(sBigMax));
 
-  { [[maybe_unused]] std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(uBigMax); }
+  std::same_as<__uint128_t> decltype(auto) _ = std::saturate_cast<__uint128_t>(uBigMax);
   assert(std::saturate_cast<__uint128_t>(    uZero) == uZero);
   assert(std::saturate_cast<__uint128_t>(  uBigMax) == uBigMax);
 #endif
diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/sub_sat.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/sub_sat.pass.cpp
index d7bdf2c0271ac..fe4255c1f7a6b 100644
--- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/sub_sat.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.sat/sub_sat.pass.cpp
@@ -26,8 +26,7 @@ constexpr bool test_signed() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]] since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::sub_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::sub_sat(minVal, maxVal);
 
   static_assert(noexcept(std::sub_sat(minVal, maxVal)));
 
@@ -89,8 +88,7 @@ constexpr bool test_unsigned() {
   constexpr auto minVal = std::numeric_limits<IntegerT>::min();
   constexpr auto maxVal = std::numeric_limits<IntegerT>::max();
 
-  // TODO(LLVM-20) remove [[maybe_unused]] since all supported compilers support "Placeholder variables with no name"
-  [[maybe_unused]] std::same_as<IntegerT> decltype(auto) _ = std::sub_sat(minVal, maxVal);
+  std::same_as<IntegerT> decltype(auto) _ = std::sub_sat(minVal, maxVal);
 
   static_assert(noexcept(std::sub_sat(minVal, maxVal)));
 



More information about the libcxx-commits mailing list