[libcxx-commits] [libcxx] cb71d77 - [libcxx][test] Add missing includes and suppress warnings

Casey Carter via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jan 13 17:34:15 PST 2022


Author: Casey Carter
Date: 2022-01-13T17:34:04-08:00
New Revision: cb71d77cc8cfb1dce7f0ae2ec51880f817d1a09b

URL: https://github.com/llvm/llvm-project/commit/cb71d77cc8cfb1dce7f0ae2ec51880f817d1a09b
DIFF: https://github.com/llvm/llvm-project/commit/cb71d77cc8cfb1dce7f0ae2ec51880f817d1a09b.diff

LOG: [libcxx][test] Add missing includes and suppress warnings

... from testing with MSVC's STL. Mostly truncation warnings and variables that are only used in `LIBCPP_ASSERT`.

Differential Revision: https://reviews.llvm.org/D116878

Added: 
    

Modified: 
    libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
    libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
    libcxx/test/std/containers/sequences/vector/access.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
    libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp
    libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp
    libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp
    libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp
    libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
    libcxx/test/std/numerics/bit/byteswap.pass.cpp
    libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp
    libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
    libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
    libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp
    libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp
    libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp
    libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp
    libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp
    libcxx/test/std/utilities/format/format.functions/format.pass.cpp
    libcxx/test/std/utilities/format/format.functions/format_tests.h
    libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
    libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
    libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
    libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
    libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp
    libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp
    libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp
    libcxx/test/support/charconv_test_helpers.h
    libcxx/test/support/test_constexpr_container.h

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
index f9ab97c97c85b..a36981cc41b02 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
@@ -16,6 +16,7 @@
 
 #include <algorithm>
 #include <iterator>
+#include <numeric>
 #include <random>
 #include <cassert>
 

diff  --git a/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp
index 6575776768494..dad468c9ecb4a 100644
--- a/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp
@@ -70,55 +70,59 @@ constexpr bool check_swap_23(T x, T y) {
 constexpr bool check_lvalue_adl_swappable() {
   auto x = lvalue_adl_swappable(0);
   auto y = lvalue_adl_swappable(1);
-  constexpr auto is_noexcept = noexcept(std::ranges::swap(x, y));
-  return check_swap_21(x, y) && is_noexcept;
+  ASSERT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_21(x, y));
+  return true;
 }
 static_assert(check_lvalue_adl_swappable());
 
 constexpr bool check_rvalue_adl_swappable() {
-  constexpr auto is_noexcept = noexcept(
-      std::ranges::swap(rvalue_adl_swappable(0), rvalue_adl_swappable(1)));
-  return check_swap_21(rvalue_adl_swappable(0), rvalue_adl_swappable(1)) &&
-         is_noexcept;
+  ASSERT_NOEXCEPT(std::ranges::swap(rvalue_adl_swappable(0), rvalue_adl_swappable(1)));
+  assert(check_swap_21(rvalue_adl_swappable(0), rvalue_adl_swappable(1)));
+  return true;
 }
 static_assert(check_rvalue_adl_swappable());
 
 constexpr bool check_lvalue_rvalue_adl_swappable() {
   auto x = lvalue_rvalue_adl_swappable(0);
-  constexpr auto is_noexcept =
-      noexcept(std::ranges::swap(x, lvalue_rvalue_adl_swappable(1)));
-  return check_swap_21(x, lvalue_rvalue_adl_swappable(1)) && is_noexcept;
+  ASSERT_NOEXCEPT(std::ranges::swap(x, lvalue_rvalue_adl_swappable(1)));
+  assert(check_swap_21(x, lvalue_rvalue_adl_swappable(1)));
+  return true;
 }
 static_assert(check_lvalue_rvalue_adl_swappable());
 
 constexpr bool check_rvalue_lvalue_adl_swappable() {
   auto x = rvalue_lvalue_adl_swappable(0);
-  constexpr auto is_noexcept =
-      noexcept(std::ranges::swap(rvalue_lvalue_adl_swappable(1), x));
-  return check_swap_21(rvalue_lvalue_adl_swappable(1), x) && is_noexcept;
+  ASSERT_NOEXCEPT(std::ranges::swap(rvalue_lvalue_adl_swappable(1), x));
+  assert(check_swap_21(rvalue_lvalue_adl_swappable(1), x));
+  return true;
 }
 static_assert(check_rvalue_lvalue_adl_swappable());
 
 constexpr bool check_throwable_swappable() {
   auto x = throwable_adl_swappable{0};
   auto y = throwable_adl_swappable{1};
-  constexpr auto not_noexcept = !noexcept(std::ranges::swap(x, y));
-  return check_swap_21(x, y) && not_noexcept;
+  ASSERT_NOT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_21(x, y));
+  return true;
 }
 static_assert(check_throwable_swappable());
 
 constexpr bool check_non_move_constructible_adl_swappable() {
   auto x = non_move_constructible_adl_swappable{0};
   auto y = non_move_constructible_adl_swappable{1};
-  constexpr auto is_noexcept = noexcept(std::ranges::swap(x, y));
-  return check_swap_21(x, y) && is_noexcept;
+  ASSERT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_21(x, y));
+  return true;
 }
 static_assert(check_non_move_constructible_adl_swappable());
 
 constexpr bool check_non_move_assignable_adl_swappable() {
   auto x = non_move_assignable_adl_swappable{0};
   auto y = non_move_assignable_adl_swappable{1};
-  return check_swap_21(x, y) && noexcept(std::ranges::swap(x, y));
+  ASSERT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_21(x, y));
+  return true;
 }
 static_assert(check_non_move_assignable_adl_swappable());
 
@@ -136,43 +140,50 @@ static_assert(std::swappable<swappable_namespace::scoped>);
 constexpr bool check_swap_arrays() {
   int x[] = {0, 1, 2, 3, 4};
   int y[] = {5, 6, 7, 8, 9};
-  return check_swap_22(x, y) && noexcept(std::ranges::swap(x, y));
+  ASSERT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_22(x, y));
+  return true;
 }
 static_assert(check_swap_arrays());
 
 constexpr bool check_lvalue_adl_swappable_arrays() {
   lvalue_adl_swappable x[] = {{0}, {1}, {2}, {3}};
   lvalue_adl_swappable y[] = {{4}, {5}, {6}, {7}};
-  return check_swap_22(x, y) && noexcept(std::ranges::swap(x, y));
+  ASSERT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_22(x, y));
+  return true;
 }
 static_assert(check_lvalue_adl_swappable_arrays());
 
 constexpr bool check_throwable_adl_swappable_arrays() {
   throwable_adl_swappable x[] = {{0}, {1}, {2}, {3}};
   throwable_adl_swappable y[] = {{4}, {5}, {6}, {7}};
-  return check_swap_22(x, y) && !noexcept(std::ranges::swap(x, y));
+  ASSERT_NOT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_22(x, y));
+  return true;
 }
 static_assert(check_throwable_adl_swappable_arrays());
 
-inline auto global_x = 0;
-static_assert(check_swap_23(0, 0) &&
-              noexcept(std::ranges::swap(global_x, global_x)));
-static_assert(check_swap_23(0, 1) &&
-              noexcept(std::ranges::swap(global_x, global_x)));
-static_assert(check_swap_23(1, 0) &&
-              noexcept(std::ranges::swap(global_x, global_x)));
+auto global_x = 0;
+ASSERT_NOEXCEPT(std::ranges::swap(global_x, global_x));
+static_assert(check_swap_23(0, 0));
+static_assert(check_swap_23(0, 1));
+static_assert(check_swap_23(1, 0));
 
 constexpr bool check_swappable_references() {
   int x = 42;
   int y = 64;
-  return check_swap_23<int&>(x, y) && noexcept(std::ranges::swap(x, y));
+  ASSERT_NOEXCEPT(std::ranges::swap(x, y));
+  assert(check_swap_23(x, y));
+  return true;
 }
 static_assert(check_swappable_references());
 
 constexpr bool check_swappable_pointers() {
   char const* x = "hello";
-  return check_swap_23<char const*>(x, nullptr) &&
-         noexcept(std::ranges::swap(x, x));
+  ASSERT_NOEXCEPT(std::ranges::swap(x, x));
+  assert(check_swap_23(x, {}));
+  return true;
 }
 static_assert(check_swappable_pointers());
 
@@ -184,7 +195,7 @@ union adl_swappable {
 
 void swap(adl_swappable&, adl_swappable&);
 void swap(adl_swappable&&, adl_swappable&&);
-}; // namespace union_swap
+} // namespace union_swap
 static_assert(std::swappable<union_swap::adl_swappable>);
 static_assert(std::swappable<union_swap::adl_swappable&>);
 static_assert(std::swappable<union_swap::adl_swappable&&>);
@@ -224,7 +235,9 @@ static_assert(std::assignable_from<swap_type&, swap_type const&>);
 static_assert(std::assignable_from<swap_type&, swap_type const>);
 static_assert(std::swappable<swap_type>);
 
-template <bool is_noexcept, std::swappable T>
+enum class nothrow { no, yes };
+
+template <nothrow is_noexcept, std::swappable T>
 void check_swap(expected<T> const& e) {
   auto a = e.y;
   auto b = e.x;
@@ -237,7 +250,7 @@ void check_swap(expected<T> const& e) {
   assert(a == e.y);
   assert(b == e.x);
 
-  static_assert(noexcept(std::ranges::swap(a, b)) == is_noexcept);
+  static_assert(noexcept(std::ranges::swap(a, b)) == bool(is_noexcept));
 }
 
 int main(int, char**) {
@@ -246,42 +259,42 @@ int main(int, char**) {
         .x = {6, 7, 8, 9},
         .y = {0, 1, 2, 3, 4, 5},
     };
-    check_swap</*is_noexcept=*/true>(e);
+    check_swap<nothrow::yes>(e);
   }
   {
     auto const e = expected<std::map<int, std::string> >{
         .x = {{0, "whole"}, {1, "cashews"}},
         .y = {{-1, "roasted"}, {2, "&"}, {-3, "salted"}},
     };
-    check_swap</*is_noexcept=*/true>(e);
+    check_swap<nothrow::yes>(e);
   }
   {
     auto const e = expected<std::string>{
         .x = "hello there",
         .y = "general kenobi",
     };
-    check_swap</*is_noexcept=*/true>(e);
+    check_swap<nothrow::yes>(e);
   }
   {
     auto const e = expected<std::optional<lvalue_adl_swappable> >{
         .x = {10},
         .y = {20},
     };
-    check_swap</*is_noexcept=*/true>(e);
+    check_swap<nothrow::yes>(e);
   }
   {
     auto const e = expected<std::optional<throwable_adl_swappable> >{
         .x = {10},
         .y = {20},
     };
-    check_swap</*is_noexcept=*/false>(e);
+    check_swap<nothrow::no>(e);
   }
   {
     auto const e = expected<std::unordered_map<int, std::string> >{
         .x = {{0, "whole"}, {1, "cashews"}},
         .y = {{-1, "roasted"}, {2, "&"}, {-3, "salted"}},
     };
-    check_swap</*is_noexcept=*/true>(e);
+    check_swap<nothrow::yes>(e);
   }
   {
     auto const e = expected<std::vector<int> >{
@@ -289,7 +302,7 @@ int main(int, char**) {
         .y = {6, 7, 8, 9},
     };
 
-    check_swap</*is_noexcept=*/true>(e);
+    check_swap<nothrow::yes>(e);
   }
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
index e1f2344bdff15..6b9ceca2b1882 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
@@ -13,6 +13,7 @@
 
 #include <vector>
 #include <cassert>
+#include <stdexcept>
 
 #include "test_macros.h"
 #include "min_allocator.h"

diff  --git a/libcxx/test/std/containers/sequences/vector/access.pass.cpp b/libcxx/test/std/containers/sequences/vector/access.pass.cpp
index 35d93db0f95f0..27d6e319460fb 100644
--- a/libcxx/test/std/containers/sequences/vector/access.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/access.pass.cpp
@@ -23,6 +23,7 @@
 
 #include <vector>
 #include <cassert>
+#include <stdexcept>
 
 #include "min_allocator.h"
 #include "test_macros.h"
@@ -39,7 +40,7 @@ make(int size, int start)
 
 template <class Vector>
 void test_get_basic(Vector& c, int start_value) {
-    const int n = c.size();
+    const int n = static_cast<int>(c.size());
     for (int i = 0; i < n; ++i)
         assert(c[i] == start_value + i);
     for (int i = 0; i < n; ++i)
@@ -47,7 +48,7 @@ void test_get_basic(Vector& c, int start_value) {
 
 #ifndef TEST_HAS_NO_EXCEPTIONS
     try {
-        c.at(n);
+        TEST_IGNORE_NODISCARD c.at(n);
         assert(false);
     } catch (const std::out_of_range&) {}
 #endif

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
index e525a752e091f..3f4aadae3a2fa 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
@@ -12,6 +12,7 @@
 
 #include <vector>
 #include <cassert>
+#include <stdexcept>
 #include "test_macros.h"
 #include "test_allocator.h"
 #include "min_allocator.h"

diff  --git a/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp
index 72dd5025b9f0f..914ad7861e6f7 100644
--- a/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp
@@ -21,12 +21,12 @@ struct Sink {
     constexpr Sink(Sink*) {}
 };
 
-constexpr int count(std::span<const Sink> sp) {
+constexpr size_t count(std::span<const Sink> sp) {
     return sp.size();
 }
 
 template<int N>
-constexpr int countn(std::span<const Sink, N> sp) {
+constexpr size_t countn(std::span<const Sink, N> sp) {
     return sp.size();
 }
 

diff  --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp
index 0327fd973af01..89db67d42bc40 100644
--- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp
+++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp
@@ -22,16 +22,26 @@
 
 struct NoIteratorAlias {
     double data_[3] = {};
-    using value_type = int;
     double *begin();
-    constexpr double *insert(double *pos, int value) {
+
+    struct value_type {
+        constexpr value_type(double d) : x(static_cast<int>(d)) {}
+        constexpr operator double() const { return x; }
+
+        int x;
+    };
+
+    template <class T>
+    constexpr double *insert(double *pos, T value) {
+        static_assert(std::is_same_v<T, value_type>);
         *pos = value;
         return pos;
     }
 };
 
 static_assert(std::is_constructible_v<std::insert_iterator<NoIteratorAlias>, NoIteratorAlias&, double*>);
-static_assert(!std::is_constructible_v<std::insert_iterator<NoIteratorAlias>, NoIteratorAlias&, int*>);
+static_assert(
+    !std::is_constructible_v<std::insert_iterator<NoIteratorAlias>, NoIteratorAlias&, NoIteratorAlias::value_type*>);
 
 constexpr bool test() {
     NoIteratorAlias c;

diff  --git a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp
index 05c68b57d5315..91ab4cfd56e48 100644
--- a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp
+++ b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp
@@ -36,9 +36,9 @@ void do_test() {
     assert(c.address() == &dummy);
   }
   {
-    C::from_address((int*)nullptr);
-    C::from_address((void*)nullptr);
-    C::from_address((char*)nullptr);
+    TEST_IGNORE_NODISCARD C::from_address((int*)nullptr);
+    TEST_IGNORE_NODISCARD C::from_address((void*)nullptr);
+    TEST_IGNORE_NODISCARD C::from_address((char*)nullptr);
   }
   {
     char dummy = 42;

diff  --git a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp
index 44dd4715552aa..6d5b9e98c4e46 100644
--- a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp
+++ b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp
@@ -30,10 +30,10 @@
 
 template <class C>
 void do_test(int *LHSVal, int *RHSVal) {
-  const size_t ExpectLHS = std::hash<void*>{}((LHSVal));
-  const size_t ExpectRHS = std::hash<void*>{}((RHSVal));
-  const C LHS = C::from_address((LHSVal));
-  const C RHS = C::from_address((RHSVal));
+  [[maybe_unused]] const size_t ExpectLHS = std::hash<void*>{}(LHSVal);
+  [[maybe_unused]] const size_t ExpectRHS = std::hash<void*>{}(RHSVal);
+  const C LHS = C::from_address(LHSVal);
+  const C RHS = C::from_address(RHSVal);
   const std::hash<C> h;
 
   LIBCPP_ASSERT(h(LHS) == ExpectLHS);

diff  --git a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
index 215f44953c5a6..19e7bb8c0205d 100644
--- a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
+++ b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp
@@ -69,7 +69,7 @@ int main(int, char**)
   assert(base);
   assert(base.done() == false);
 
-  h.promise();
+  TEST_IGNORE_NODISCARD h.promise();
   assert(h.address() == base.address());
   assert(h == base);
   assert(h.address() != nullptr);

diff  --git a/libcxx/test/std/numerics/bit/byteswap.pass.cpp b/libcxx/test/std/numerics/bit/byteswap.pass.cpp
index 076dc4343a395..ea72fbb631802 100644
--- a/libcxx/test/std/numerics/bit/byteswap.pass.cpp
+++ b/libcxx/test/std/numerics/bit/byteswap.pass.cpp
@@ -41,8 +41,10 @@ constexpr std::pair<T, T> get_test_data() {
     return {static_cast<T>(0x60AF8503), static_cast<T>(0x0385AF60)};
   case 8:
     return {static_cast<T>(0xABCDFE9477936406), static_cast<T>(0x0664937794FECDAB)};
+  default:
+    assert(false);
+    return {}; // for MSVC, whose `assert` is tragically not [[noreturn]]
   }
-  assert(false);
 }
 
 template <class T>
@@ -57,8 +59,8 @@ constexpr bool test() {
   test_num<uint32_t>(0x01234567, 0x67452301);
   test_num<uint64_t>(0x0123456789ABCDEF, 0xEFCDAB8967452301);
 
-  test_num<int8_t>(0xAB, 0xAB);
-  test_num<int16_t>(0xCDEF, 0xEFCD);
+  test_num<int8_t>(static_cast<int8_t>(0xAB), static_cast<int8_t>(0xAB));
+  test_num<int16_t>(static_cast<int16_t>(0xCDEF), static_cast<int16_t>(0xEFCD));
   test_num<int32_t>(0x01234567, 0x67452301);
   test_num<int64_t>(0x0123456789ABCDEF, 0xEFCDAB8967452301);
 
@@ -71,7 +73,7 @@ constexpr bool test() {
 
   test_num<bool>(true, true);
   test_num<bool>(false, false);
-  test_num<char>(0xCD, 0xCD);
+  test_num<char>(static_cast<char>(0xCD), static_cast<char>(0xCD));
   test_num<unsigned char>(0xEF, 0xEF);
   test_num<signed char>(0x45, 0x45);
   test_num<char8_t>(0xAB, 0xAB);

diff  --git a/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp
index b125f76de9e49..ae1fbe173b53e 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp
@@ -21,10 +21,10 @@ struct Decrementable {
 
   auto operator<=>(const Decrementable&) const = default;
 
-  constexpr Decrementable& operator++();
-  constexpr Decrementable  operator++(int);
-  constexpr Decrementable& operator--();
-  constexpr Decrementable  operator--(int);
+  Decrementable& operator++();
+  Decrementable  operator++(int);
+  Decrementable& operator--();
+  Decrementable  operator--(int);
 };
 
 struct Incrementable {
@@ -32,8 +32,8 @@ struct Incrementable {
 
   auto operator<=>(const Incrementable&) const = default;
 
-  constexpr Incrementable& operator++();
-  constexpr Incrementable  operator++(int);
+  Incrementable& operator++();
+  Incrementable  operator++(int);
 };
 
 static_assert(std::ranges::random_access_range<std::ranges::iota_view<int>>);

diff  --git a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
index 4491b0f60eabe..1ccf23e5e21a1 100644
--- a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp
@@ -65,7 +65,8 @@ constexpr bool test() {
   }
   {
     const std::ranges::iota_view<int, int> io(0, std::numeric_limits<int>::max());
-    assert(io.size() == std::numeric_limits<int>::max());
+    constexpr auto imax = std::numeric_limits<int>::max();
+    assert(io.size() == imax);
   }
 
   // Neither are integer like.

diff  --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
index 36b3a2a6c81a1..3f97537dd2df0 100644
--- a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
@@ -13,6 +13,7 @@
 // template<class Operation>
 // void resize_and_overwrite(size_type n, Operation op)
 
+#include <algorithm>
 #include <cassert>
 #include <string>
 

diff  --git a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp
index fe7a42de005bf..5472944af6684 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp
@@ -31,7 +31,7 @@ template <class CharT>
 void test() {
   using Context = std::basic_format_context<CharT*, CharT>;
   {
-    auto store = std::make_format_args<Context>();
+    [[maybe_unused]] auto store = std::make_format_args<Context>();
     LIBCPP_STATIC_ASSERT(
         std::is_same_v<decltype(store), std::__format_arg_store<Context>>);
     LIBCPP_STATIC_ASSERT(
@@ -40,7 +40,7 @@ void test() {
     LIBCPP_ASSERT(store.__args.size() == 0);
   }
   {
-    auto store = std::make_format_args<Context>(1);
+    [[maybe_unused]] auto store = std::make_format_args<Context>(1);
     LIBCPP_STATIC_ASSERT(
         std::is_same_v<decltype(store), std::__format_arg_store<Context, int>>);
     LIBCPP_STATIC_ASSERT(
@@ -49,7 +49,7 @@ void test() {
     LIBCPP_ASSERT(store.__args.size() == 1);
   }
   {
-    auto store = std::make_format_args<Context>(1, 'c');
+    [[maybe_unused]] auto store = std::make_format_args<Context>(1, 'c');
     LIBCPP_STATIC_ASSERT(
         std::is_same_v<decltype(store),
                        std::__format_arg_store<Context, int, char>>);
@@ -59,7 +59,7 @@ void test() {
     LIBCPP_ASSERT(store.__args.size() == 2);
   }
   {
-    auto store = std::make_format_args<Context>(1, 'c', nullptr);
+    [[maybe_unused]] auto store = std::make_format_args<Context>(1, 'c', nullptr);
     LIBCPP_STATIC_ASSERT(
         std::is_same_v<decltype(store),
                        std::__format_arg_store<Context, int, char, std::nullptr_t>>);

diff  --git a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp
index 98e2c1799a56d..d40feb64e3670 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp
@@ -25,10 +25,10 @@
 #include "test_macros.h"
 
 int main(int, char**) {
-  using Context = std::basic_format_context<
+  using Context [[maybe_unused]] = std::basic_format_context<
       std::back_insert_iterator<std::basic_string<char>>, char>;
 
-  auto value = std::make_format_args(42, nullptr, false, 1.0);
+  [[maybe_unused]] auto value = std::make_format_args(42, nullptr, false, 1.0);
 
   LIBCPP_ASSERT(value.__args.size() == 4);
   LIBCPP_ASSERT(test_basic_format_arg(value.__args[0], 42));

diff  --git a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp
index 9b3a567f914ba..9657ca30c0301 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp
@@ -25,10 +25,10 @@
 #include "test_macros.h"
 
 int main(int, char**) {
-  using Context = std::basic_format_context<
+  using Context [[maybe_unused]] = std::basic_format_context<
       std::back_insert_iterator<std::basic_string<wchar_t>>, wchar_t>;
 
-  auto value = std::make_wformat_args(42, nullptr, false, 1.0);
+  [[maybe_unused]] auto value = std::make_wformat_args(42, nullptr, false, 1.0);
 
   LIBCPP_ASSERT(value.__args.size() == 4);
   LIBCPP_ASSERT(test_basic_format_arg(value.__args[0], 42));

diff  --git a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp
index 910059b422a31..7e8d778ad8225 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp
@@ -35,11 +35,11 @@ constexpr bool test() {
 void test_exception() {
   [] {
     std::format_parse_context context("", 1);
-    context.next_arg_id();
+    TEST_IGNORE_NODISCARD context.next_arg_id();
     try {
       context.check_arg_id(0);
       assert(false);
-    } catch (const std::format_error& e) {
+    } catch ([[maybe_unused]] const std::format_error& e) {
       LIBCPP_ASSERT(strcmp(e.what(), "Using manual argument numbering in automatic "
                                      "argument numbering mode") == 0);
       return;

diff  --git a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp
index 72f2b026840e1..a88b6966ed481 100644
--- a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp
@@ -37,9 +37,9 @@ void test_exception() {
   context.check_arg_id(0);
 
   try {
-    context.next_arg_id();
+    TEST_IGNORE_NODISCARD context.next_arg_id();
     assert(false);
-  } catch (const std::format_error& e) {
+  } catch ([[maybe_unused]] const std::format_error& e) {
     LIBCPP_ASSERT(strcmp(e.what(), "Using automatic argument numbering in manual "
                                    "argument numbering mode") == 0);
     return;

diff  --git a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp
index b6dffd864742e..7963b1500f1c5 100644
--- a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp
@@ -67,11 +67,10 @@ auto test_exception = []<class CharT, class... Args>(
     return;
   }
   assert(false);
-#else
+#endif
   (void)what;
   (void)fmt;
   (void)sizeof...(args);
-#endif
 };
 
 int main(int, char**) {

diff  --git a/libcxx/test/std/utilities/format/format.functions/format_tests.h b/libcxx/test/std/utilities/format/format.functions/format_tests.h
index f5a888eb35bfc..54d304327b6ca 100644
--- a/libcxx/test/std/utilities/format/format.functions/format_tests.h
+++ b/libcxx/test/std/utilities/format/format.functions/format_tests.h
@@ -165,7 +165,7 @@ void format_test_string(T world, T universe, TestFunction check,
       STR("hello {:{}}"), world, -1);
   check_exception(
       "A format-spec arg-id replacement exceeds the maximum supported value",
-      STR("hello {:{}}"), world, -1u);
+      STR("hello {:{}}"), world, unsigned(-1));
   check_exception("Argument index out of bounds", STR("hello {:{}}"), world);
   check_exception(
       "A format-spec arg-id replacement argument isn't an integral type",
@@ -201,7 +201,7 @@ void format_test_string(T world, T universe, TestFunction check,
       STR("hello {:.{}}"), world, -1);
   check_exception(
       "A format-spec arg-id replacement exceeds the maximum supported value",
-      STR("hello {:.{}}"), world, -1u);
+      STR("hello {:.{}}"), world, ~0u);
   check_exception("Argument index out of bounds", STR("hello {:.{}}"), world);
   check_exception(
       "A format-spec arg-id replacement argument isn't an integral type",

diff  --git a/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
index eb98907098c90..c9dbab1002c4e 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp
@@ -36,19 +36,18 @@ auto test_exception = []<class CharT, class... Args>(
     std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
 #ifndef TEST_HAS_NO_EXCEPTIONS
   try {
-    std::vformat(std::locale(), fmt,
-                 std::make_format_args<context_t<CharT>>(args...));
+    (void) std::vformat(std::locale(), fmt,
+                        std::make_format_args<context_t<CharT>>(args...));
     assert(false);
-  } catch (std::format_error& e) {
+  } catch ([[maybe_unused]] std::format_error& e) {
     LIBCPP_ASSERT(e.what() == what);
     return;
   }
   assert(false);
-#else
+#endif
   (void)what;
   (void)fmt;
   (void)sizeof...(args);
-#endif
 };
 
 int main(int, char**) {

diff  --git a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
index 26f7ae0f35c11..8688d560c41c6 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp
@@ -35,18 +35,17 @@ auto test_exception = []<class CharT, class... Args>(
     std::string_view what, std::basic_string<CharT> fmt, const Args&... args) {
 #ifndef TEST_HAS_NO_EXCEPTIONS
   try {
-    std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
+    TEST_IGNORE_NODISCARD std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
     assert(false);
-  } catch (std::format_error& e) {
+  } catch ([[maybe_unused]] std::format_error& e) {
     LIBCPP_ASSERT(e.what() == what);
     return;
   }
   assert(false);
-#else
+#endif
   (void)what;
   (void)fmt;
   (void)sizeof...(args);
-#endif
 };
 
 int main(int, char**) {

diff  --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
index 40fc629cfb928..737f618085591 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp
@@ -74,16 +74,15 @@ auto test_exception = []<class CharT, class... Args>(
     std::vformat_to(std::back_inserter(out), std::locale(), fmt,
                     std::make_format_args<context_t<CharT>>(args...));
     assert(false);
-  } catch (std::format_error& e) {
+  } catch ([[maybe_unused]] std::format_error& e) {
     LIBCPP_ASSERT(e.what() == what);
     return;
   }
   assert(false);
-#else
+#endif
   (void)what;
   (void)fmt;
   (void)sizeof...(args);
-#endif
 };
 
 int main(int, char**) {

diff  --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
index 6ebca904e0890..0bec98a13b7a2 100644
--- a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp
@@ -74,16 +74,15 @@ auto test_exception = []<class CharT, class... Args>(
     std::vformat_to(std::back_inserter(out), fmt,
                     std::make_format_args<context_t<CharT>>(args...));
     assert(false);
-  } catch (std::format_error& e) {
+  } catch ([[maybe_unused]] std::format_error& e) {
     LIBCPP_ASSERT(e.what() == what);
     return;
   }
   assert(false);
-#else
+#endif
   (void)what;
   (void)fmt;
   (void)sizeof...(args);
-#endif
 };
 
 int main(int, char**) {

diff  --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp
index 5b4d11beb87f0..d8594bc03b132 100644
--- a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp
@@ -73,9 +73,9 @@ class Z
 {
     int i_;
 public:
-    constexpr explicit Z(int i) : i_(i) { TEST_THROW(6);}
+    explicit Z(int i) : i_(i) {TEST_THROW(6);}
 
-    friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+    friend bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
 };
 
 template<class T, class U>

diff  --git a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp
index 24cc9c5b80bda..1e29073bba2d9 100644
--- a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp
@@ -380,7 +380,7 @@ void test_derived_from_variant() {
   // Check that visit unambiguously picks the variant, even if the other base has __impl member.
   struct ImplVariantBase {
     struct Callable {
-      bool operator()();
+      bool operator()() const { assert(false); return false; }
     };
 
     Callable __impl;

diff  --git a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp
index ab8f754d2559d..3ae53727df44d 100644
--- a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp
@@ -451,7 +451,7 @@ void test_derived_from_variant() {
   // Check that visit unambiguously picks the variant, even if the other base has __impl member.
   struct ImplVariantBase {
     struct Callable {
-      bool operator()();
+      bool operator()() const { assert(false); return false; }
     };
 
     Callable __impl;

diff  --git a/libcxx/test/support/charconv_test_helpers.h b/libcxx/test/support/charconv_test_helpers.h
index bbce485976b13..006e9021145c1 100644
--- a/libcxx/test/support/charconv_test_helpers.h
+++ b/libcxx/test/support/charconv_test_helpers.h
@@ -108,7 +108,7 @@ struct to_chars_test_base
 
         // Poison the buffer for testing whether a successful std::to_chars
         // doesn't modify data beyond r.ptr.
-        std::iota(buf, buf + sizeof(buf), 1);
+        std::iota(buf, buf + sizeof(buf), char(1));
         r = to_chars(buf, buf + sizeof(buf), v, args...);
         assert(r.ec == std::errc{});
         for (size_t i = r.ptr - buf; i < sizeof(buf); ++i)

diff  --git a/libcxx/test/support/test_constexpr_container.h b/libcxx/test/support/test_constexpr_container.h
index 3f466d517cccb..fa57244630177 100644
--- a/libcxx/test/support/test_constexpr_container.h
+++ b/libcxx/test/support/test_constexpr_container.h
@@ -38,7 +38,7 @@ class ConstexprFixedCapacityDeque {
     constexpr const T& back() const { assert(size_ >= 1); return data_[size_-1]; }
 
     constexpr iterator insert(const_iterator pos, T t) {
-        int i = (pos - data_);
+        int i = static_cast<int>(pos - data_);
         if (i != size_) {
             std::move_backward(data_ + i, data_ + size_, data_ + size_ + 1);
         }


        


More information about the libcxx-commits mailing list