[libcxx-commits] [libcxx] [libc++] Diagnose unused variables of some classes (PR #202011)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 5 23:43:54 PDT 2026


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/202011

None

>From 095e4a718ddb43a8c66529e129a1f6fafdd066b4 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sat, 6 Jun 2026 08:43:29 +0200
Subject: [PATCH] [libc++] Diagnose unused variables of some classes

---
 .../__condition_variable/condition_variable.h |   2 +-
 libcxx/include/__exception/exception.h        |   8 +-
 libcxx/include/__exception/exception_ptr.h    |   2 +-
 libcxx/include/__exception/nested_exception.h |   2 +-
 .../include/__expected/bad_expected_access.h  |   2 +-
 libcxx/include/__expected/expected.h          |   4 +-
 libcxx/include/__expected/unexpected.h        |   2 +-
 libcxx/include/__filesystem/directory_entry.h |   2 +-
 .../include/__filesystem/directory_iterator.h |   2 +-
 libcxx/include/__filesystem/file_status.h     |   2 +-
 .../include/__filesystem/filesystem_error.h   |   2 +-
 libcxx/include/__filesystem/path.h            |   2 +-
 libcxx/include/__filesystem/path_iterator.h   |   2 +-
 .../recursive_directory_iterator.h            |   2 +-
 libcxx/include/__flat_map/flat_map.h          |   2 +-
 libcxx/include/__flat_map/flat_multimap.h     |   2 +-
 libcxx/include/__flat_set/flat_multiset.h     |   2 +-
 libcxx/include/__flat_set/flat_set.h          |   2 +-
 libcxx/include/__format/format_arg.h          |   2 +-
 libcxx/include/__format/format_context.h      |   2 +-
 libcxx/include/__format/format_error.h        |   2 +-
 libcxx/include/__functional/function.h        |   4 +-
 .../include/__functional/reference_wrapper.h  |   2 +-
 .../include/__iterator/back_insert_iterator.h |   2 +-
 .../__iterator/front_insert_iterator.h        |   2 +-
 libcxx/include/__iterator/insert_iterator.h   |   2 +-
 libcxx/include/__iterator/istream_iterator.h  |   2 +-
 .../include/__iterator/istreambuf_iterator.h  |   2 +-
 libcxx/include/__iterator/move_iterator.h     |   2 +-
 libcxx/include/__ostream/basic_ostream.h      |   2 +-
 libcxx/include/__vector/vector.h              |   2 +-
 libcxx/include/__vector/vector_bool.h         |   2 +-
 libcxx/include/any                            |   2 +-
 libcxx/include/barrier                        |   2 +-
 libcxx/include/condition_variable             |   2 +-
 libcxx/include/deque                          |   4 +-
 libcxx/include/forward_list                   |   2 +-
 libcxx/include/fstream                        |   8 +-
 libcxx/include/future                         |  22 +--
 libcxx/include/istream                        |   6 +-
 libcxx/include/list                           |   2 +-
 libcxx/include/map                            |   4 +-
 libcxx/include/set                            |   4 +-
 libcxx/include/string                         |   2 +-
 libcxx/include/unordered_map                  |   4 +-
 libcxx/include/unordered_set                  |   4 +-
 libcxx/src/filesystem/directory_iterator.cpp  |   1 -
 .../sequence/sequence_container_benchmarks.h  |   1 -
 ...st_comparator.incomplete.compile.pass.cpp} |   3 +-
 .../non_const_comparator.verify.cpp           |   4 +
 .../vector/robust_against_adl.pass.cpp        |   1 +
 ...st_comparator.incomplete.compile.pass.cpp} |   3 +-
 .../unord/non_const_comparator.verify.cpp     |   4 +
 .../missing_hash_specialization.verify.cpp    |   3 +
 .../diagnostics/unused_variables.verify.cpp   | 141 ++++++++++++++++++
 .../last_write_time.pass.cpp                  |   1 -
 .../filesystems/nodiscard.verify.cpp          |   1 -
 .../strings/basic.string/nonnull.verify.cpp   |   2 +-
 .../constinit_sso_string.compile.pass.cpp     |   2 +-
 .../from_range_associative_containers.h       |   2 +
 .../associative/map/incomplete_type.pass.cpp  |   1 +
 .../copy_assign.addressof.compile.pass.cpp    |   2 +
 .../multimap/incomplete_type.pass.cpp         |   1 +
 .../copy_assign.addressof.compile.pass.cpp    |   2 +
 .../copy_assign.addressof.compile.pass.cpp    |   1 +
 .../copy_assign.addressof.compile.pass.cpp    |   1 +
 ....cpp => default_noexcept.compile.pass.cpp} |  41 +----
 ...ass.cpp => dtor_noexcept.compile.pass.cpp} |  26 +---
 .../flat.map.cons/move_exceptions.pass.cpp    |   2 +
 ...ass.cpp => move_noexcept.compile.pass.cpp} |  51 ++-----
 ....cpp => default_noexcept.compile.pass.cpp} |  43 +-----
 ...ass.cpp => dtor_noexcept.compile.pass.cpp} |  25 +---
 .../move_exceptions.pass.cpp                  |   2 +
 ...ass.cpp => move_noexcept.compile.pass.cpp} |  56 ++-----
 .../robust_against_nonbool.compile.pass.cpp   |   2 +
 .../flat.multiset.cons/default.pass.cpp       |  27 +---
 .../flat.multiset.cons/dtor_noexcept.pass.cpp |   4 -
 .../flat.multiset.cons/move.pass.cpp          |  37 ++---
 .../robust_against_nonbool.compile.pass.cpp   |   1 +
 .../flat.set/flat.set.cons/default.pass.cpp   |  28 +---
 .../flat.set.cons/dtor_noexcept.pass.cpp      |   4 -
 .../flat.set/flat.set.cons/move.pass.cpp      |  37 ++---
 .../robust_against_nonbool.compile.pass.cpp   |   1 +
 .../move_assign.addressof.compile.pass.cpp    |   1 +
 .../forwardlist/exception_safety.pass.cpp     |   2 +
 .../assign_copy.addressof.compile.pass.cpp    |   1 +
 .../from_range_sequence_containers.h          |   1 +
 .../sequences/list/exception_safety.pass.cpp  |   1 +
 .../assign_copy.addressof.compile.pass.cpp    |   1 +
 .../assign_move.addressof.compile.pass.cpp    |   1 +
 .../list/list.cons/input_iterator.pass.cpp    |   6 +
 .../vector.bool/ctor_exceptions.pass.cpp      |  13 ++
 .../vector/addressof.compile.pass.cpp         |   2 +
 .../vector.cons/construct_iter_iter.pass.cpp  |   9 ++
 .../construct_iter_iter_alloc.pass.cpp        |   9 ++
 .../vector/vector.cons/exceptions.pass.cpp    |  18 +++
 .../unord/from_range_unordered_containers.h   |   3 +
 .../unord/unord.map/incomplete_type.pass.cpp  |   1 +
 .../assign_copy.addressof.compile.pass.cpp    |   2 +
 .../assign_move.addressof.compile.pass.cpp    |   2 +
 .../move.addressof.compile.pass.cpp           |   1 +
 .../move_alloc.addressof.compile.pass.cpp     |   1 +
 .../unord/unord.multimap/incomplete.pass.cpp  |   1 +
 .../assign_copy.addressof.compile.pass.cpp    |   2 +
 .../move.addressof.compile.pass.cpp           |   1 +
 .../move_alloc.addressof.compile.pass.cpp     |   1 +
 .../assign_copy.addressof.compile.pass.cpp    |   1 +
 .../move.addressof.compile.pass.cpp           |   1 +
 .../move_alloc.addressof.compile.pass.cpp     |   1 +
 .../assign_copy.addressof.compile.pass.cpp    |   1 +
 .../move.addressof.compile.pass.cpp           |   1 +
 .../move_alloc.addressof.compile.pass.cpp     |   1 +
 .../fstreams/fstream.cons/default.pass.cpp    |   4 +
 .../fstreams/ifstream.cons/default.pass.cpp   |   4 +
 .../fstreams/ifstream.cons/path.pass.cpp      |   1 -
 .../fstreams/ofstream.cons/default.pass.cpp   |   4 +
 .../directory_entry.cons/copy.pass.cpp        |   2 +-
 .../directory_entry.cons/copy_assign.pass.cpp |   2 +-
 .../directory_entry.cons/move.pass.cpp        |   2 +-
 .../directory_entry.cons/move_assign.pass.cpp |   2 +-
 .../directory_entry.cons/path.pass.cpp        |   4 +-
 .../directory_entry.mods/assign.pass.cpp      |   4 +-
 .../directory_entry.mods/refresh.pass.cpp     |   3 +-
 .../replace_filename.pass.cpp                 |   4 +-
 .../directory_entry.obs/file_size.pass.cpp    |   4 +-
 .../file_type_obs.pass.cpp                    |   1 +
 .../hard_link_count.pass.cpp                  |   2 +-
 .../last_write_time.pass.cpp                  |   2 +-
 .../directory_entry.obs/path.pass.cpp         |   1 -
 .../directory_iterator.members/ctor.pass.cpp  |   1 +
 .../filesystem_error.members.pass.cpp         |   1 -
 .../rec.dir.itr.members/copy_assign.pass.cpp  |   2 -
 .../recursion_pending.pass.cpp                |   1 -
 .../fs.op.funcs/fs.op.copy/copy.pass.cpp      |   4 +-
 .../create_directories.pass.cpp               |   2 +-
 .../fs.op.is_empty/is_empty.pass.cpp          |   2 +-
 .../back.insert.iter.cons/container.pass.cpp  |   1 +
 .../front.insert.iter.cons/container.pass.cpp |   1 +
 .../insert.iter.cons/test.pass.cpp            |   1 +
 .../facet.ctype.char.members/scan_is.pass.cpp |   2 -
 .../scan_not.pass.cpp                         |   2 -
 .../locale.ctype.byname/scan_is.pass.cpp      |   3 -
 .../locale.ctype.byname/scan_not.pass.cpp     |   3 -
 .../locale.ctype.members/scan_is.pass.cpp     |   2 -
 .../locale.ctype.members/scan_not.pass.cpp    |   1 -
 .../locale.time.put.members/put2.pass.cpp     |   8 +-
 .../conversions.string/converted.pass.cpp     |  12 +-
 .../range.lazy.split/general.pass.cpp         |   3 -
 .../range.split/general.pass.cpp              |   3 -
 .../to_std_containers.pass.cpp                |   1 -
 .../re.regex.construct/il_flg.pass.cpp        |   5 -
 .../string.cons/T_size_size.pass.cpp          |   2 +
 .../basic.string/string.cons/dtor.pass.cpp    |   1 +
 .../string.cons/from_range.pass.cpp           |   1 +
 .../string.cons/move_alloc.pass.cpp           |   1 +
 .../basic.string/string.cons/substr.pass.cpp  |   1 +
 .../string.ops/string_substr/substr.pass.cpp  |   2 +-
 .../thread_create_failure.pass.cpp            |   2 +
 .../futures.async/wait_on_destruct.pass.cpp   |   2 +-
 .../futures.promise/get_future.pass.cpp       |   3 +
 .../futures.promise/set_rvalue.pass.cpp       |   1 +
 .../futures.promise/set_value_const.pass.cpp  |   1 +
 .../futures.task.members/get_future.pass.cpp  |   1 +
 .../default.pass.cpp                          |   1 +
 .../any/any.class/any.cons/copy.pass.cpp      |   1 +
 .../any/any.class/any.cons/value.pass.cpp     |   1 +
 .../ctor/ctor.default.pass.cpp                |   1 +
 .../ctor/ctor.inplace.pass.cpp                |   1 +
 .../ctor/ctor.inplace_init_list.pass.cpp      |   1 +
 .../expected.expected/ctor/ctor.u.pass.cpp    |   1 +
 .../ctor/ctor.unexpect.pass.cpp               |   1 +
 .../ctor/ctor.unexpect_init_list.pass.cpp     |   1 +
 .../expected/expected.expected/dtor.pass.cpp  |   1 +
 .../ctor/ctor.error.pass.cpp                  |   1 +
 .../ctor/ctor.inplace.pass.cpp                |   1 +
 .../ctor/ctor.inplace_init_list.pass.cpp      |   1 +
 .../expected.void/ctor/ctor.unexpect.pass.cpp |   1 +
 .../ctor/ctor.unexpect_init_list.pass.cpp     |   1 +
 .../bad_function_call_ctor.pass.cpp           |   1 +
 .../func.wrap.func.con/F_incomplete.pass.cpp  |   7 -
 .../noncopyable_return_type.pass.cpp          |  12 ++
 .../robust_against_adl.pass.cpp               |   1 +
 .../equal.refwrap.refwrap.pass.cpp            |   2 -
 .../equal.refwrap.refwrap_const.pass.cpp      |   1 -
 .../tuple/tuple.tuple/TupleFunction.pass.cpp  |   1 +
 .../header_deque_synop2.pass.cpp              |   1 +
 .../header_list_synop2.pass.cpp               |   1 +
 .../header_map_synop2.pass.cpp                |   2 +
 .../header_set_synop2.pass.cpp                |   2 +
 .../header_string_synop2.pass.cpp             |   4 +
 .../header_unordered_map_synop2.pass.cpp      |   2 +
 .../header_unordered_set_synop2.pass.cpp      |   2 +
 .../header_vector_synop2.pass.cpp             |   1 +
 193 files changed, 526 insertions(+), 446 deletions(-)
 rename libcxx/test/libcxx/containers/associative/{non_const_comparator.incomplete.verify.cpp => non_const_comparator.incomplete.compile.pass.cpp} (98%)
 rename libcxx/test/libcxx/containers/unord/{non_const_comparator.incomplete.verify.cpp => non_const_comparator.incomplete.compile.pass.cpp} (98%)
 create mode 100644 libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp
 rename libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/{default_noexcept.pass.cpp => default_noexcept.compile.pass.cpp} (55%)
 rename libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/{dtor_noexcept.pass.cpp => dtor_noexcept.compile.pass.cpp} (85%)
 rename libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/{move_noexcept.pass.cpp => move_noexcept.compile.pass.cpp} (60%)
 rename libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/{default_noexcept.pass.cpp => default_noexcept.compile.pass.cpp} (60%)
 rename libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/{dtor_noexcept.pass.cpp => dtor_noexcept.compile.pass.cpp} (86%)
 rename libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/{move_noexcept.pass.cpp => move_noexcept.compile.pass.cpp} (63%)

diff --git a/libcxx/include/__condition_variable/condition_variable.h b/libcxx/include/__condition_variable/condition_variable.h
index 3fa40287c3600..9be484ba71b03 100644
--- a/libcxx/include/__condition_variable/condition_variable.h
+++ b/libcxx/include/__condition_variable/condition_variable.h
@@ -87,7 +87,7 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::
   return nanoseconds(__result);
 }
 
-class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] condition_variable {
   __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
 
 public:
diff --git a/libcxx/include/__exception/exception.h b/libcxx/include/__exception/exception.h
index c5f37d5fd1611..ae056293a2035 100644
--- a/libcxx/include/__exception/exception.h
+++ b/libcxx/include/__exception/exception.h
@@ -40,7 +40,7 @@ struct __std_exception_data {
   bool _DoFree;
 };
 
-class exception { // base of all library exceptions
+class [[__gnu__::__warn_unused__]] exception { // base of all library exceptions
 public:
   exception() _NOEXCEPT : __data_() {}
 
@@ -63,7 +63,7 @@ class exception { // base of all library exceptions
   __std_exception_data __data_;
 };
 
-class bad_exception : public exception {
+class [[__gnu__::__warn_unused__]] bad_exception : public exception {
 public:
   bad_exception() _NOEXCEPT : exception("bad exception") {}
 };
@@ -72,7 +72,7 @@ class bad_exception : public exception {
 // On all other platforms, we define our own std::exception and std::bad_exception types
 // regardless of whether exceptions are turned on as a language feature.
 
-class _LIBCPP_EXPORTED_FROM_ABI exception {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] exception {
 public:
   _LIBCPP_HIDE_FROM_ABI exception() _NOEXCEPT {}
   _LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT            = default;
@@ -82,7 +82,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception {
   [[__nodiscard__]] virtual const char* what() const _NOEXCEPT;
 };
 
-class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] bad_exception : public exception {
 public:
   _LIBCPP_HIDE_FROM_ABI bad_exception() _NOEXCEPT {}
   _LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT            = default;
diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h
index f7ed00d555836..90f86bb3db94d 100644
--- a/libcxx/include/__exception/exception_ptr.h
+++ b/libcxx/include/__exception/exception_ptr.h
@@ -66,7 +66,7 @@ _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT;
 
-class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] exception_ptr {
   void* __ptr_;
 
   static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
diff --git a/libcxx/include/__exception/nested_exception.h b/libcxx/include/__exception/nested_exception.h
index f8abe7db50de7..7723ceeb67135 100644
--- a/libcxx/include/__exception/nested_exception.h
+++ b/libcxx/include/__exception/nested_exception.h
@@ -30,7 +30,7 @@
 _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
-class _LIBCPP_EXPORTED_FROM_ABI nested_exception {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] nested_exception {
   exception_ptr __ptr_;
 
 public:
diff --git a/libcxx/include/__expected/bad_expected_access.h b/libcxx/include/__expected/bad_expected_access.h
index d0ba175c04c92..9ec43389071e3 100644
--- a/libcxx/include/__expected/bad_expected_access.h
+++ b/libcxx/include/__expected/bad_expected_access.h
@@ -54,7 +54,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_expected_access<void> : public exception {
 _LIBCPP_DIAGNOSTIC_POP
 
 template <class _Err>
-class bad_expected_access : public bad_expected_access<void> {
+class [[__gnu__::__warn_unused__]] bad_expected_access : public bad_expected_access<void> {
 public:
   _LIBCPP_HIDE_FROM_ABI explicit bad_expected_access(_Err __e) : __unex_(std::move(__e)) {}
 
diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h
index 27bc086698399..1745bc2070a93 100644
--- a/libcxx/include/__expected/expected.h
+++ b/libcxx/include/__expected/expected.h
@@ -448,7 +448,7 @@ class __expected_base {
 };
 
 template <class _Tp, class _Err>
-class expected : private __expected_base<_Tp, _Err> {
+class [[__gnu__::__warn_unused__]] expected : private __expected_base<_Tp, _Err> {
   static_assert(!is_reference_v<_Tp> && !is_function_v<_Tp> && !is_same_v<remove_cv_t<_Tp>, in_place_t> &&
                     !is_same_v<remove_cv_t<_Tp>, unexpect_t> && !__is_std_unexpected<remove_cv_t<_Tp>>::value &&
                     __valid_std_unexpected<_Err>::value,
@@ -1379,7 +1379,7 @@ class __expected_void_base {
 
 template <class _Tp, class _Err>
   requires is_void_v<_Tp>
-class expected<_Tp, _Err> : private __expected_void_base<_Err> {
+class [[__gnu__::__warn_unused__]] expected<_Tp, _Err> : private __expected_void_base<_Err> {
   static_assert(__valid_std_unexpected<_Err>::value,
                 "[expected.void.general] A program that instantiates expected<T, E> with a E that is not a "
                 "valid argument for unexpected<E> is ill-formed");
diff --git a/libcxx/include/__expected/unexpected.h b/libcxx/include/__expected/unexpected.h
index fc4f52ce14adc..2f726ca5bc3e7 100644
--- a/libcxx/include/__expected/unexpected.h
+++ b/libcxx/include/__expected/unexpected.h
@@ -57,7 +57,7 @@ using __valid_std_unexpected _LIBCPP_NODEBUG = _BoolConstant< //
     >;
 
 template <class _Err>
-class unexpected {
+class [[__gnu__::__warn_unused__]] unexpected {
   static_assert(__valid_std_unexpected<_Err>::value,
                 "[expected.un.general] states a program that instantiates std::unexpected for a non-object type, an "
                 "array type, a specialization of unexpected, or a cv-qualified type is ill-formed.");
diff --git a/libcxx/include/__filesystem/directory_entry.h b/libcxx/include/__filesystem/directory_entry.h
index d741984b34fee..058d3d0733d6a 100644
--- a/libcxx/include/__filesystem/directory_entry.h
+++ b/libcxx/include/__filesystem/directory_entry.h
@@ -41,7 +41,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
-class directory_entry {
+class [[__gnu__::__warn_unused__]] directory_entry {
   typedef filesystem::path _Path;
 
 public:
diff --git a/libcxx/include/__filesystem/directory_iterator.h b/libcxx/include/__filesystem/directory_iterator.h
index 52a5bf59a2c80..37c605c8cbd9e 100644
--- a/libcxx/include/__filesystem/directory_iterator.h
+++ b/libcxx/include/__filesystem/directory_iterator.h
@@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 class _LIBCPP_HIDDEN __dir_stream;
-class directory_iterator {
+class [[__gnu__::__warn_unused__]] directory_iterator {
 public:
   typedef directory_entry value_type;
   typedef ptrdiff_t difference_type;
diff --git a/libcxx/include/__filesystem/file_status.h b/libcxx/include/__filesystem/file_status.h
index 746cd0f9a680c..ca5d9a2a6b1b7 100644
--- a/libcxx/include/__filesystem/file_status.h
+++ b/libcxx/include/__filesystem/file_status.h
@@ -22,7 +22,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 
-class file_status {
+class [[__gnu__::__warn_unused__]] file_status {
 public:
   // constructors
   _LIBCPP_HIDE_FROM_ABI file_status() noexcept : file_status(file_type::none) {}
diff --git a/libcxx/include/__filesystem/filesystem_error.h b/libcxx/include/__filesystem/filesystem_error.h
index 054e38111b415..3fdd2aaa0cf22 100644
--- a/libcxx/include/__filesystem/filesystem_error.h
+++ b/libcxx/include/__filesystem/filesystem_error.h
@@ -28,7 +28,7 @@
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
-class _LIBCPP_EXPORTED_FROM_ABI filesystem_error : public system_error {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] filesystem_error : public system_error {
 public:
   _LIBCPP_HIDE_FROM_ABI filesystem_error(const string& __what, error_code __ec)
       : system_error(__ec, __what), __storage_(make_shared<_Storage>(path(), path())) {
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index a63c4ee611ebf..1af03156e4cff 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -371,7 +371,7 @@ struct _PathExport<char8_t> {
 #    endif   // _LIBCPP_HAS_LOCALIZATION
 #  endif     // _LIBCPP_WIN32API
 
-class _LIBCPP_EXPORTED_FROM_ABI path {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] path {
   template <class _SourceOrIter, class _Tp = path&>
   using _EnableIfPathable _LIBCPP_NODEBUG = __enable_if_t<__is_pathable<_SourceOrIter>::value, _Tp>;
 
diff --git a/libcxx/include/__filesystem/path_iterator.h b/libcxx/include/__filesystem/path_iterator.h
index 30a9a5a059af7..eb8594f14e6b8 100644
--- a/libcxx/include/__filesystem/path_iterator.h
+++ b/libcxx/include/__filesystem/path_iterator.h
@@ -24,7 +24,7 @@
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
-class _LIBCPP_EXPORTED_FROM_ABI path::iterator {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] path::iterator {
 public:
   enum _ParserState : unsigned char {
     _Singular,
diff --git a/libcxx/include/__filesystem/recursive_directory_iterator.h b/libcxx/include/__filesystem/recursive_directory_iterator.h
index 99665d017a101..97010f983dc74 100644
--- a/libcxx/include/__filesystem/recursive_directory_iterator.h
+++ b/libcxx/include/__filesystem/recursive_directory_iterator.h
@@ -34,7 +34,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
-class recursive_directory_iterator {
+class [[__gnu__::__warn_unused__]] recursive_directory_iterator {
 public:
   using value_type        = directory_entry;
   using difference_type   = ptrdiff_t;
diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h
index 50487cada24c0..483f09c78cfe4 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -81,7 +81,7 @@ template <class _Key,
           class _Compare         = less<_Key>,
           class _KeyContainer    = vector<_Key>,
           class _MappedContainer = vector<_Tp>>
-class flat_map {
+class [[__gnu__::__warn_unused__]] flat_map {
   template <class, class, class, class, class>
   friend class flat_map;
 
diff --git a/libcxx/include/__flat_map/flat_multimap.h b/libcxx/include/__flat_map/flat_multimap.h
index bd3ec81b98b7f..d6ac1d9b71471 100644
--- a/libcxx/include/__flat_map/flat_multimap.h
+++ b/libcxx/include/__flat_map/flat_multimap.h
@@ -78,7 +78,7 @@ template <class _Key,
           class _Compare         = less<_Key>,
           class _KeyContainer    = vector<_Key>,
           class _MappedContainer = vector<_Tp>>
-class flat_multimap {
+class [[__gnu__::__warn_unused__]] flat_multimap {
   template <class, class, class, class, class>
   friend class flat_multimap;
 
diff --git a/libcxx/include/__flat_set/flat_multiset.h b/libcxx/include/__flat_set/flat_multiset.h
index 4324645fb8445..d427d03416612 100644
--- a/libcxx/include/__flat_set/flat_multiset.h
+++ b/libcxx/include/__flat_set/flat_multiset.h
@@ -68,7 +68,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Key, class _Compare = less<_Key>, class _KeyContainer = vector<_Key>>
-class flat_multiset {
+class [[__gnu__::__warn_unused__]] flat_multiset {
   template <class, class, class>
   friend class flat_multiset;
 
diff --git a/libcxx/include/__flat_set/flat_set.h b/libcxx/include/__flat_set/flat_set.h
index 57c3926e33b68..1315ac1f61aae 100644
--- a/libcxx/include/__flat_set/flat_set.h
+++ b/libcxx/include/__flat_set/flat_set.h
@@ -70,7 +70,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Key, class _Compare = less<_Key>, class _KeyContainer = vector<_Key>>
-class flat_set {
+class [[__gnu__::__warn_unused__]] flat_set {
   template <class, class, class>
   friend class flat_set;
 
diff --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h
index 19794f0f084ce..fa3ac51393a89 100644
--- a/libcxx/include/__format/format_arg.h
+++ b/libcxx/include/__format/format_arg.h
@@ -277,7 +277,7 @@ class __basic_format_arg_value {
 };
 
 template <class _Context>
-class _LIBCPP_NO_SPECIALIZATIONS basic_format_arg {
+class _LIBCPP_NO_SPECIALIZATIONS [[__gnu__::__warn_unused__]] basic_format_arg {
 public:
   class handle;
 
diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h
index cf3131b80e52f..4f3774954b9a6 100644
--- a/libcxx/include/__format/format_context.h
+++ b/libcxx/include/__format/format_context.h
@@ -68,7 +68,7 @@ using wformat_context = basic_format_context< back_insert_iterator<__format::__o
 
 template <class _OutIt, class _CharT>
 class _LIBCPP_PREFERRED_NAME(format_context) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context))
-    basic_format_context {
+    [[__gnu__::__warn_unused__]] basic_format_context {
 public:
   using iterator  = _OutIt;
   using char_type = _CharT;
diff --git a/libcxx/include/__format/format_error.h b/libcxx/include/__format/format_error.h
index 853b4c1c3e75b..b337606a4527a 100644
--- a/libcxx/include/__format/format_error.h
+++ b/libcxx/include/__format/format_error.h
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 _LIBCPP_DIAGNOSTIC_PUSH
 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
-class _LIBCPP_EXPORTED_FROM_ABI format_error : public runtime_error {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] format_error : public runtime_error {
 public:
   _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s) : runtime_error(__s) {}
   _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s) : runtime_error(__s) {}
diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index d62b6b06722a7..be612a4acc8f6 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -49,7 +49,7 @@ _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 #  if !_LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION
 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
 #  endif
-class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] bad_function_call : public exception {
 public:
   _LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT                                    = default;
   _LIBCPP_HIDE_FROM_ABI bad_function_call(const bad_function_call&) _NOEXCEPT            = default;
@@ -605,7 +605,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_Ar
 } // namespace __function
 
 template <class _Rp, class... _ArgTypes>
-class function<_Rp(_ArgTypes...)>
+class [[__gnu__::__warn_unused__]] function<_Rp(_ArgTypes...)>
     : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
       public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> {
 #  ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
diff --git a/libcxx/include/__functional/reference_wrapper.h b/libcxx/include/__functional/reference_wrapper.h
index b1efd9f76d877..14aa863b22d1e 100644
--- a/libcxx/include/__functional/reference_wrapper.h
+++ b/libcxx/include/__functional/reference_wrapper.h
@@ -35,7 +35,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp>
-class reference_wrapper : public __weak_result_type<_Tp> {
+class [[__gnu__::__warn_unused__]] reference_wrapper : public __weak_result_type<_Tp> {
 public:
   // types
   typedef _Tp type;
diff --git a/libcxx/include/__iterator/back_insert_iterator.h b/libcxx/include/__iterator/back_insert_iterator.h
index 456653ab36f33..2177625ffe39c 100644
--- a/libcxx/include/__iterator/back_insert_iterator.h
+++ b/libcxx/include/__iterator/back_insert_iterator.h
@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Container>
-class back_insert_iterator
+class [[__gnu__::__warn_unused__]] back_insert_iterator
     : public __iterator_base<back_insert_iterator<_Container>, output_iterator_tag, void, void, void, void> {
 protected:
   _Container* container;
diff --git a/libcxx/include/__iterator/front_insert_iterator.h b/libcxx/include/__iterator/front_insert_iterator.h
index 477f1c711256b..5ce3cfb432d5c 100644
--- a/libcxx/include/__iterator/front_insert_iterator.h
+++ b/libcxx/include/__iterator/front_insert_iterator.h
@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Container>
-class front_insert_iterator
+class [[__gnu__::__warn_unused__]] front_insert_iterator
     : public __iterator_base<front_insert_iterator<_Container>, output_iterator_tag, void, void, void, void> {
 protected:
   _Container* container;
diff --git a/libcxx/include/__iterator/insert_iterator.h b/libcxx/include/__iterator/insert_iterator.h
index f70fe570722a0..9d284176a964d 100644
--- a/libcxx/include/__iterator/insert_iterator.h
+++ b/libcxx/include/__iterator/insert_iterator.h
@@ -36,7 +36,7 @@ using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator;
 #endif
 
 template <class _Container>
-class insert_iterator
+class [[__gnu__::__warn_unused__]] insert_iterator
     : public __iterator_base<insert_iterator<_Container>, output_iterator_tag, void, void, void, void> {
 protected:
   _Container* container;
diff --git a/libcxx/include/__iterator/istream_iterator.h b/libcxx/include/__iterator/istream_iterator.h
index 0b759eebfb00b..237c61a183f9b 100644
--- a/libcxx/include/__iterator/istream_iterator.h
+++ b/libcxx/include/__iterator/istream_iterator.h
@@ -26,7 +26,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
-class istream_iterator
+class [[__gnu__::__warn_unused__]] istream_iterator
     : public __iterator_base<istream_iterator<_Tp, _CharT, _Traits, _Distance>,
                              input_iterator_tag,
                              _Tp,
diff --git a/libcxx/include/__iterator/istreambuf_iterator.h b/libcxx/include/__iterator/istreambuf_iterator.h
index c554a05f6717c..f4ad895d4a964 100644
--- a/libcxx/include/__iterator/istreambuf_iterator.h
+++ b/libcxx/include/__iterator/istreambuf_iterator.h
@@ -26,7 +26,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _CharT, class _Traits>
-class istreambuf_iterator
+class [[__gnu__::__warn_unused__]] istreambuf_iterator
     : public __iterator_base<istreambuf_iterator<_CharT, _Traits>,
                              input_iterator_tag,
                              _CharT,
diff --git a/libcxx/include/__iterator/move_iterator.h b/libcxx/include/__iterator/move_iterator.h
index c42f4cb53e9a8..e2e120c86b4f7 100644
--- a/libcxx/include/__iterator/move_iterator.h
+++ b/libcxx/include/__iterator/move_iterator.h
@@ -64,7 +64,7 @@ concept __move_iter_comparable = requires {
 #endif // _LIBCPP_STD_VER >= 20
 
 template <class _Iter>
-class move_iterator
+class [[__gnu__::__warn_unused__]] move_iterator
 #if _LIBCPP_STD_VER >= 20
     : public __move_iter_category_base<_Iter>
 #endif
diff --git a/libcxx/include/__ostream/basic_ostream.h b/libcxx/include/__ostream/basic_ostream.h
index 43c9399758bf1..79b3eb5674e85 100644
--- a/libcxx/include/__ostream/basic_ostream.h
+++ b/libcxx/include/__ostream/basic_ostream.h
@@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 template <class _CharT, class _Traits>
-class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
+class [[__gnu__::__warn_unused__]] basic_ostream : virtual public basic_ios<_CharT, _Traits> {
 public:
   // types (inherited from basic_ios (27.5.4)):
   typedef _CharT char_type;
diff --git a/libcxx/include/__vector/vector.h b/libcxx/include/__vector/vector.h
index 2a081e3cdb1e2..ff998f9dd883b 100644
--- a/libcxx/include/__vector/vector.h
+++ b/libcxx/include/__vector/vector.h
@@ -84,7 +84,7 @@ _LIBCPP_PUSH_MACROS
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Tp, class _Allocator /* = allocator<_Tp> */>
-class vector {
+class [[__gnu__::__warn_unused__]] vector {
   using _SplitBuffer _LIBCPP_NODEBUG = std::__split_buffer<_Tp, _Allocator, __split_buffer_pointer_layout>;
 
 public:
diff --git a/libcxx/include/__vector/vector_bool.h b/libcxx/include/__vector/vector_bool.h
index f73e086478a70..ad13678e2262b 100644
--- a/libcxx/include/__vector/vector_bool.h
+++ b/libcxx/include/__vector/vector_bool.h
@@ -77,7 +77,7 @@ struct __has_storage_type<vector<bool, _Allocator> > {
 };
 
 template <class _Allocator>
-class vector<bool, _Allocator> {
+class [[__gnu__::__warn_unused__]] vector<bool, _Allocator> {
 public:
   using __self _LIBCPP_NODEBUG         = vector;
   using value_type                     = bool;
diff --git a/libcxx/include/any b/libcxx/include/any
index 6157713a4069f..02638434788a6 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -192,7 +192,7 @@ using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _Sma
 
 } // namespace __any_imp
 
-class any {
+class [[__gnu__::__warn_unused__]] any {
 public:
   // construct/destruct
   _LIBCPP_HIDE_FROM_ABI constexpr any() noexcept : __h_(nullptr) {}
diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 7fda4c8e06179..02191a9fe14b7 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -151,7 +151,7 @@ public:
 };
 
 template <class _CompletionF = __empty_completion>
-class barrier {
+class [[__gnu__::__warn_unused__]] barrier {
   __barrier_base<_CompletionF> __b_;
 
 public:
diff --git a/libcxx/include/condition_variable b/libcxx/include/condition_variable
index a6b5f842f3bc8..e857c7e2701a2 100644
--- a/libcxx/include/condition_variable
+++ b/libcxx/include/condition_variable
@@ -163,7 +163,7 @@ struct __unlock_guard {
   __unlock_guard& operator=(const __unlock_guard&) = delete;
 };
 
-class _LIBCPP_EXPORTED_FROM_ABI condition_variable_any {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] condition_variable_any {
   condition_variable __cv_;
   shared_ptr<mutex> __mut_;
 
diff --git a/libcxx/include/deque b/libcxx/include/deque
index bf589b05aef72..bcb91a52abbb8 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -282,7 +282,7 @@ template <class _ValueType,
               __deque_block_size<_ValueType, _DiffType>::value
 #  endif
           >
-class __deque_iterator {
+class [[__gnu__::__warn_unused__]] __deque_iterator {
   using __map_iterator _LIBCPP_NODEBUG = __rebind_pointer_t<_Pointer, const __rebind_pointer_t<_Pointer, _ValueType> >;
 
 // TODO(LLVM 25): Remove this check
@@ -495,7 +495,7 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,
     __deque_block_size<_ValueType, _DiffType>::value;
 
 template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
-class deque {
+class [[__gnu__::__warn_unused__]] deque {
   template <class _Up, class _Alloc>
   using __split_buffer _LIBCPP_NODEBUG = std::__split_buffer<_Up, _Alloc, __split_buffer_pointer_layout>;
 
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 6d86f7a8e5975..a3e586f360ae8 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -625,7 +625,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __forward_list_base<_Tp, _Alloc>::clear() _NO
 }
 
 template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
-class forward_list : private __forward_list_base<_Tp, _Alloc> {
+class [[__gnu__::__warn_unused__]] forward_list : private __forward_list_base<_Tp, _Alloc> {
   typedef __forward_list_base<_Tp, _Alloc> __base;
   typedef typename __base::__node_allocator __node_allocator;
   typedef typename __base::__node_type __node_type;
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index b5fb65820628a..f3c0d3e9a9401 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -227,7 +227,7 @@ _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) no
 #    endif
 
 template <class _CharT, class _Traits>
-class basic_filebuf : public basic_streambuf<_CharT, _Traits> {
+class [[__gnu__::__warn_unused__]] basic_filebuf : public basic_streambuf<_CharT, _Traits> {
 public:
   typedef _CharT char_type;
   typedef _Traits traits_type;
@@ -1143,7 +1143,7 @@ void basic_filebuf<_CharT, _Traits>::__write_mode() {
 // basic_ifstream
 
 template <class _CharT, class _Traits>
-class basic_ifstream : public basic_istream<_CharT, _Traits> {
+class [[__gnu__::__warn_unused__]] basic_ifstream : public basic_istream<_CharT, _Traits> {
 public:
   typedef _CharT char_type;
   typedef _Traits traits_type;
@@ -1299,7 +1299,7 @@ inline void basic_ifstream<_CharT, _Traits>::close() {
 // basic_ofstream
 
 template <class _CharT, class _Traits>
-class basic_ofstream : public basic_ostream<_CharT, _Traits> {
+class [[__gnu__::__warn_unused__]] basic_ofstream : public basic_ostream<_CharT, _Traits> {
 public:
   typedef _CharT char_type;
   typedef _Traits traits_type;
@@ -1458,7 +1458,7 @@ inline void basic_ofstream<_CharT, _Traits>::close() {
 // basic_fstream
 
 template <class _CharT, class _Traits>
-class basic_fstream : public basic_iostream<_CharT, _Traits> {
+class [[__gnu__::__warn_unused__]] basic_fstream : public basic_iostream<_CharT, _Traits> {
 public:
   typedef _CharT char_type;
   typedef _Traits traits_type;
diff --git a/libcxx/include/future b/libcxx/include/future
index c169c6c182d83..bf2fc7d5bfa1e 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -922,7 +922,7 @@ template <class _Rp, class _Fp>
 _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f);
 
 template <class _Rp>
-class future {
+class [[__gnu__::__warn_unused__]] future {
   __assoc_state<_Rp>* __state_;
 
   explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp>* __state);
@@ -993,7 +993,7 @@ _Rp future<_Rp>::get() {
 }
 
 template <class _Rp>
-class future<_Rp&> {
+class [[__gnu__::__warn_unused__]] future<_Rp&> {
   __assoc_state<_Rp&>* __state_;
 
   explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp&>* __state);
@@ -1060,7 +1060,7 @@ _Rp& future<_Rp&>::get() {
 }
 
 template <>
-class _LIBCPP_EXPORTED_FROM_ABI future<void> {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] future<void> {
   __assoc_sub_state* __state_;
 
   explicit future(__assoc_sub_state* __state);
@@ -1118,7 +1118,7 @@ template <class _Callable>
 class packaged_task;
 
 template <class _Rp>
-class promise {
+class [[__gnu__::__warn_unused__]] promise {
   __assoc_state<_Rp>* __state_;
 
   _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
@@ -1235,7 +1235,7 @@ void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) {
 // promise<R&>
 
 template <class _Rp>
-class promise<_Rp&> {
+class [[__gnu__::__warn_unused__]] promise<_Rp&> {
   __assoc_state<_Rp&>* __state_;
 
   _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
@@ -1336,7 +1336,7 @@ void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) {
 // promise<void>
 
 template <>
-class _LIBCPP_EXPORTED_FROM_ABI promise<void> {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] promise<void> {
   __assoc_sub_state* __state_;
 
   _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
@@ -1607,7 +1607,7 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes...
 }
 
 template <class _Rp, class... _ArgTypes>
-class packaged_task<_Rp(_ArgTypes...)> {
+class [[__gnu__::__warn_unused__]] packaged_task<_Rp(_ArgTypes...)> {
 private:
   __packaged_task_function<_Rp(_ArgTypes...)> __f_;
   promise<_Rp> __p_;
@@ -1698,7 +1698,7 @@ void packaged_task<_Rp(_ArgTypes...)>::reset() {
 }
 
 template <class... _ArgTypes>
-class packaged_task<void(_ArgTypes...)> {
+class [[__gnu__::__warn_unused__]] packaged_task<void(_ArgTypes...)> {
 private:
   __packaged_task_function<void(_ArgTypes...)> __f_;
   promise<void> __p_;
@@ -1890,7 +1890,7 @@ async(_Fp&& __f, _Args&&... __args) {
 // shared_future
 
 template <class _Rp>
-class shared_future {
+class [[__gnu__::__warn_unused__]] shared_future {
   __assoc_state<_Rp>* __state_;
 
 public:
@@ -1946,7 +1946,7 @@ shared_future<_Rp>& shared_future<_Rp>::operator=(const shared_future& __rhs) _N
 }
 
 template <class _Rp>
-class shared_future<_Rp&> {
+class [[__gnu__::__warn_unused__]] shared_future<_Rp&> {
   __assoc_state<_Rp&>* __state_;
 
 public:
@@ -2002,7 +2002,7 @@ shared_future<_Rp&>& shared_future<_Rp&>::operator=(const shared_future& __rhs)
 }
 
 template <>
-class _LIBCPP_EXPORTED_FROM_ABI shared_future<void> {
+class _LIBCPP_EXPORTED_FROM_ABI [[__gnu__::__warn_unused__]] shared_future<void> {
   __assoc_sub_state* __state_;
 
 public:
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 640cd9f4e29fb..003e3cb09def5 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -193,7 +193,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
 
 template <class _CharT, class _Traits>
-class basic_istream : virtual public basic_ios<_CharT, _Traits> {
+class [[__gnu__::__warn_unused__]] basic_istream : virtual public basic_ios<_CharT, _Traits> {
   streamsize __gc_;
 
   _LIBCPP_HIDE_FROM_ABI void __inc_gcount() {
@@ -1175,7 +1175,9 @@ _LIBCPP_HIDE_FROM_ABI _Stream&& operator>>(_Stream&& __is, _Tp&& __x) {
 }
 
 template <class _CharT, class _Traits>
-class basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> {
+class [[__gnu__::__warn_unused__]] basic_iostream
+    : public basic_istream<_CharT, _Traits>,
+      public basic_ostream<_CharT, _Traits> {
 public:
   // types:
   typedef _CharT char_type;
diff --git a/libcxx/include/list b/libcxx/include/list
index 3223f25e1cfba..82bbd339f5730 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -672,7 +672,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c
 }
 
 template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
-class list : private __list_imp<_Tp, _Alloc> {
+class [[__gnu__::__warn_unused__]] list : private __list_imp<_Tp, _Alloc> {
   typedef __list_imp<_Tp, _Alloc> __base;
   typedef typename __base::__node_type __node_type;
   typedef typename __base::__node_allocator __node_allocator;
diff --git a/libcxx/include/map b/libcxx/include/map
index c983a3ed07cd4..b99b8ffd13e9c 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -937,7 +937,7 @@ template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator =
 class multimap;
 
 template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >
-class map {
+class [[__gnu__::__warn_unused__]] map {
 public:
   // types:
   typedef _Key key_type;
@@ -1718,7 +1718,7 @@ struct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > {
 };
 
 template <class _Key, class _Tp, class _Compare, class _Allocator>
-class multimap {
+class [[__gnu__::__warn_unused__]] multimap {
 public:
   // types:
   typedef _Key key_type;
diff --git a/libcxx/include/set b/libcxx/include/set
index 3f2d2cd164d2d..6e078f297307e 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -573,7 +573,7 @@ template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<
 class multiset;
 
 template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >
-class set {
+class [[__gnu__::__warn_unused__]] set {
 public:
   // types:
   typedef _Key key_type;
@@ -1064,7 +1064,7 @@ struct __container_traits<set<_Key, _Compare, _Allocator> > {
 };
 
 template <class _Key, class _Compare, class _Allocator>
-class multiset {
+class [[__gnu__::__warn_unused__]] multiset {
 public:
   // types:
   typedef _Key key_type;
diff --git a/libcxx/include/string b/libcxx/include/string
index a201d2ca44354..e618ab0321158 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -730,7 +730,7 @@ template <>
 struct __padding<0> {};
 
 template <class _CharT, class _Traits, class _Allocator>
-class basic_string {
+class [[__gnu__::__warn_unused__]] basic_string {
 public:
   using __self _LIBCPP_NODEBUG         = basic_string;
   using __self_view _LIBCPP_NODEBUG    = basic_string_view<_CharT, _Traits>;
diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map
index 8cefba01fb5f6..3c9b6984982bd 100644
--- a/libcxx/include/unordered_map
+++ b/libcxx/include/unordered_map
@@ -881,7 +881,7 @@ template <class _Key,
           class _Hash  = hash<_Key>,
           class _Pred  = equal_to<_Key>,
           class _Alloc = allocator<pair<const _Key, _Tp> > >
-class unordered_map {
+class [[__gnu__::__warn_unused__]] unordered_map {
 public:
   // types
   typedef _Key key_type;
@@ -1678,7 +1678,7 @@ template <class _Key,
           class _Hash  = hash<_Key>,
           class _Pred  = equal_to<_Key>,
           class _Alloc = allocator<pair<const _Key, _Tp> > >
-class unordered_multimap {
+class [[__gnu__::__warn_unused__]] unordered_multimap {
 public:
   // types
   typedef _Key key_type;
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index d54d59403b038..9ec85dcac18bd 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -591,7 +591,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
 class unordered_multiset;
 
 template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
-class unordered_set {
+class [[__gnu__::__warn_unused__]] unordered_set {
 public:
   // types
   typedef _Value key_type;
@@ -1207,7 +1207,7 @@ struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > {
 };
 
 template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
-class unordered_multiset {
+class [[__gnu__::__warn_unused__]] unordered_multiset {
 public:
   // types
   typedef _Value key_type;
diff --git a/libcxx/src/filesystem/directory_iterator.cpp b/libcxx/src/filesystem/directory_iterator.cpp
index 5d682aee2b839..6a0c35a61b375 100644
--- a/libcxx/src/filesystem/directory_iterator.cpp
+++ b/libcxx/src/filesystem/directory_iterator.cpp
@@ -257,7 +257,6 @@ recursive_directory_iterator& recursive_directory_iterator::__increment(error_co
 void recursive_directory_iterator::__advance(error_code* ec) {
   ErrorHandler<void> err("recursive_directory_iterator::operator++()", ec);
 
-  const directory_iterator end_it;
   auto& stack = __imp_->__stack_;
   error_code m_ec;
   while (stack.size() > 0) {
diff --git a/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h b/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
index 92346c38563fb..08c54320172ed 100644
--- a/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
@@ -333,7 +333,6 @@ void sequence_container_benchmarks(std::string container) {
           };
 
           std::vector<Container> c(BatchSize, at_capacity(Container(in.begin(), in.end())));
-          std::vector<Container> const original = c;
 
           while (st.KeepRunningBatch(BatchSize)) {
             for (std::size_t i = 0; i != BatchSize; ++i) {
diff --git a/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.verify.cpp b/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.compile.pass.cpp
similarity index 98%
rename from libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.verify.cpp
rename to libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.compile.pass.cpp
index bae78ba4b78c6..79c35165b2f06 100644
--- a/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.verify.cpp
+++ b/libcxx/test/libcxx/containers/associative/non_const_comparator.incomplete.compile.pass.cpp
@@ -33,6 +33,7 @@ void test_set() {
   struct KeyDerived : KeyBase {};
 
   C c; // ODR use it, which should be OK
+  (void)c;
 }
 
 template <template <typename...> class Container>
@@ -45,10 +46,10 @@ void test_map() {
   (void)dummy;
   struct KeyDerived : KeyBase {};
   C c;
+  (void)c;
 }
 
 void f() {
-  // expected-no-diagnostics
   test_set<std::set>();
   test_set<std::multiset>();
   test_map<std::map>();
diff --git a/libcxx/test/libcxx/containers/associative/non_const_comparator.verify.cpp b/libcxx/test/libcxx/containers/associative/non_const_comparator.verify.cpp
index cb7a044abd8c0..6bf6e903a3cb0 100644
--- a/libcxx/test/libcxx/containers/associative/non_const_comparator.verify.cpp
+++ b/libcxx/test/libcxx/containers/associative/non_const_comparator.verify.cpp
@@ -32,17 +32,21 @@ void f() {
   {
     using C = std::set<int, BadCompare>;
     C s;
+    (void)s;
   }
   {
     using C = std::multiset<long, BadCompare>;
     C s;
+    (void)s;
   }
   {
     using C = std::map<int, int, BadCompare>;
     C s;
+    (void)s;
   }
   {
     using C = std::multimap<long, int, BadCompare>;
     C s;
+    (void)s;
   }
 }
diff --git a/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp b/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp
index c6868ce4cb867..db1e92dea55fe 100644
--- a/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp
@@ -34,6 +34,7 @@ struct MyAlloc {
 
 int main(int, char**) {
   std::vector<bool, MyAlloc<bool>> vb;
+  (void)vb;
   // std::fill_n triggers ADL because __bit_iterator has the container type as a template argument
   // std::vector<bool, MyAlloc<bool>> wb(100);
 
diff --git a/libcxx/test/libcxx/containers/unord/non_const_comparator.incomplete.verify.cpp b/libcxx/test/libcxx/containers/unord/non_const_comparator.incomplete.compile.pass.cpp
similarity index 98%
rename from libcxx/test/libcxx/containers/unord/non_const_comparator.incomplete.verify.cpp
rename to libcxx/test/libcxx/containers/unord/non_const_comparator.incomplete.compile.pass.cpp
index c370cd65085a1..48bc39805c8a0 100644
--- a/libcxx/test/libcxx/containers/unord/non_const_comparator.incomplete.verify.cpp
+++ b/libcxx/test/libcxx/containers/unord/non_const_comparator.incomplete.compile.pass.cpp
@@ -35,6 +35,7 @@ void test_set() {
   struct KeyDerived : KeyBase {};
 
   C c; // ODR use it, which should be OK
+  (void)c;
 }
 
 template <template <typename...> class Container>
@@ -47,10 +48,10 @@ void test_map() {
   (void)dummy;
   struct KeyDerived : KeyBase {};
   C c;
+  (void)c;
 }
 
 void f() {
-  // expected-no-diagnostics
   test_set<std::unordered_set>();
   test_set<std::unordered_multiset>();
   test_map<std::unordered_map>();
diff --git a/libcxx/test/libcxx/containers/unord/non_const_comparator.verify.cpp b/libcxx/test/libcxx/containers/unord/non_const_comparator.verify.cpp
index c3418302d0315..d758378d82fa8 100644
--- a/libcxx/test/libcxx/containers/unord/non_const_comparator.verify.cpp
+++ b/libcxx/test/libcxx/containers/unord/non_const_comparator.verify.cpp
@@ -42,17 +42,21 @@ void f() {
   {
     using C = std::unordered_set<int, BadHash, BadEqual>;
     C s;
+    (void)s;
   }
   {
     using C = std::unordered_multiset<long, BadHash, BadEqual>;
     C s;
+    (void)s;
   }
   {
     using C = std::unordered_map<int, int, BadHash, BadEqual>;
     C s;
+    (void)s;
   }
   {
     using C = std::unordered_multimap<long, int, BadHash, BadEqual>;
     C s;
+    (void)s;
   }
 }
diff --git a/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.verify.cpp b/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.verify.cpp
index c66496acc6d07..fc7dc49caab34 100644
--- a/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.verify.cpp
+++ b/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.verify.cpp
@@ -56,14 +56,17 @@ int main(int, char**) {
   {
     using Set = std::unordered_set<int, BadHashNoCopy>;
     Set s; // expected-error at __hash_table:* {{the specified hash does not meet the Hash requirements}}
+    (void)s;
   }
   {
     using Set = std::unordered_set<int, BadHashNoCall>;
     Set s; // expected-error at __hash_table:* {{the specified hash does not meet the Hash requirements}}
+    (void)s;
   }
   {
     using Set = std::unordered_set<int, GoodHashNoDefault>;
     Set s(/*bucketcount*/ 42, GoodHashNoDefault(nullptr));
+    (void)s;
   }
 
   return 0;
diff --git a/libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp b/libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp
new file mode 100644
index 0000000000000..ded68b73719a6
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/unused_variables.verify.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <any>
+#include <barrier>
+#include <condition_variable>
+#include <deque>
+#include <exception>
+#include <expected>
+#include <filesystem>
+#include <flat_map>
+#include <flat_set>
+#include <format>
+#include <forward_list>
+#include <fstream>
+#include <functional>
+#include <future>
+#include <iterator>
+#include <iostream>
+#include <list>
+#include <map>
+#include <set>
+#include <unordered_map>
+#include <unordered_set>
+#include <vector>
+
+namespace fs = std::filesystem;
+
+template <class T>
+T get();
+
+void containers() {
+  std::deque<int> a;                   // expected-warning {{unused variable}}
+  std::deque<int>::iterator b;         // expected-warning {{unused variable}}
+  std::forward_list<int> c;            // expected-warning {{unused variable}}
+  std::list<int> d;                    // expected-warning {{unused variable}}
+  std::map<int, int> e;                // expected-warning {{unused variable}}
+  std::multimap<int, int> f;           // expected-warning {{unused variable}}
+  std::set<int> g;                     // expected-warning {{unused variable}}
+  std::multiset<int> h;                // expected-warning {{unused variable}}
+  std::unordered_map<int, int> i;      // expected-warning {{unused variable}}
+  std::unordered_multimap<int, int> j; // expected-warning {{unused variable}}
+  std::unordered_set<int> k;           // expected-warning {{unused variable}}
+  std::unordered_multiset<int> l;      // expected-warning {{unused variable}}
+  std::string m;                       // expected-warning {{unused variable}}
+  std::vector<int> n;                  // expected-warning {{unused variable}}
+  std::vector<bool> o;                 // expected-warning {{unused variable}}
+}
+
+void container_adaptors() {
+  std::flat_map<int, int> a;      // expected-warning {{unused variable}}
+  std::flat_multimap<int, int> b; // expected-warning {{unused variable}}
+  std::flat_set<int> c;           // expected-warning {{unused variable}}
+  std::flat_multiset<int> d;      // expected-warning {{unused variable}}
+}
+
+void expected() {
+  std::bad_expected_access<int> a(0); // expected-warning {{unused variable}}
+  std::expected<void, std::any> b;    // expected-warning {{unused variable}}
+  std::expected<int, std::any> c;     // expected-warning {{unused variable}}
+  std::unexpected<std::any> d(1);     // expected-warning {{unused variable}}
+}
+
+void filesystem() {
+  fs::directory_entry a;              // expected-warning {{unused variable}}
+  fs::directory_iterator b;           // expected-warning {{unused variable}}
+  fs::file_status c;                  // expected-warning {{unused variable}}
+  fs::filesystem_error d("", {});     // expected-warning {{unused variable}}
+  fs::path e;                         // expected-warning {{unused variable}}
+  fs::path::iterator f;               // expected-warning {{unused variable}}
+  fs::recursive_directory_iterator g; // expected-warning {{unused variable}}
+}
+
+void format() {
+  std::basic_format_arg<std::format_context> a; // expected-warning {{unused variable}}
+  auto b = get<std::format_context>();          // expected-warning {{unused variable}}
+  std::format_error c("");                      // expected-warning {{unused variable}}
+}
+
+void future() {
+  std::future<void> a;          // expected-warning {{unused variable}}
+  std::future<int&> b;          // expected-warning {{unused variable}}
+  std::future<int> c;           // expected-warning {{unused variable}}
+  std::promise<void> d;         // expected-warning {{unused variable}}
+  std::promise<int&> e;         // expected-warning {{unused variable}}
+  std::promise<int> f;          // expected-warning {{unused variable}}
+  std::packaged_task<void()> g; // expected-warning {{unused variable}}
+  std::packaged_task<int()> h;  // expected-warning {{unused variable}}
+  std::shared_future<void> i;   // expected-warning {{unused variable}}
+  std::shared_future<int&> j;   // expected-warning {{unused variable}}
+  std::shared_future<int> k;    // expected-warning {{unused variable}}
+}
+
+void generic_exceptions() {
+  std::exception a;        // expected-warning {{unused variable}}
+  std::bad_exception b;    // expected-warning {{unused variable}}
+  std::exception_ptr c;    // expected-warning {{unused variable}}
+  std::nested_exception d; // expected-warning {{unused variable}}
+}
+
+void iterator() {
+  using C = std::deque<int>;
+  C container;
+
+  std::back_insert_iterator<C> a(container);               // expected-warning {{unused variable}}
+  std::front_insert_iterator<C> b(container);              // expected-warning {{unused variable}}
+  std::insert_iterator<C> c(container, container.begin()); // expected-warning {{unused variable}}
+  std::istream_iterator<char> d    = std::cin;             // expected-warning {{unused variable}}
+  std::istreambuf_iterator<char> e = std::cin;             // expected-warning {{unused variable}}
+  std::move_iterator<C::iterator> f;                       // expected-warning {{unused variable}}
+}
+
+void streams() {
+  std::ifstream a; // expected-warning {{unused variable}}
+  std::ofstream b; // expected-warning {{unused variable}}
+  std::fstream c;  // expected-warning {{unused variable}}
+  std::filebuf d;  // expected-warning {{unused variable}}
+  std::filebuf buf;
+  std::istream e(&buf);  // expected-warning {{unused variable}}
+  std::ostream f(&buf);  // expected-warning {{unused variable}}
+  std::iostream g(&buf); // expected-warning {{unused variable}}
+}
+
+void synchronization() {
+  std::barrier<> a(0);           // expected-warning {{unused variable}}
+  std::condition_variable b;     // expected-warning {{unused variable}}
+  std::condition_variable_any c; // expected-warning {{unused variable}}
+}
+
+void other() {
+  std::any a; // expected-warning {{unused variable}}
+  int bi;
+  std::reference_wrapper<int> b(bi); // expected-warning {{unused variable}}
+  std::bad_function_call c;          // expected-warning {{unused variable}}
+  std::function<void()> d;           // expected-warning {{unused variable}}
+}
diff --git a/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp b/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp
index 7f7a39557c0cf..415ece20c5313 100644
--- a/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp
+++ b/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp
@@ -40,7 +40,6 @@ static void last_write_time_not_representable_error() {
   using namespace fs;
   using namespace std::chrono;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
 
   TimeSpec ToTime;
diff --git a/libcxx/test/libcxx/input.output/filesystems/nodiscard.verify.cpp b/libcxx/test/libcxx/input.output/filesystems/nodiscard.verify.cpp
index 413e7ba7a6165..5d8223d6ec37b 100644
--- a/libcxx/test/libcxx/input.output/filesystems/nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/input.output/filesystems/nodiscard.verify.cpp
@@ -290,7 +290,6 @@ void test() {
 
   {
     std::filesystem::path p;
-    const std::string src;
 
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
     p.native();
diff --git a/libcxx/test/libcxx/strings/basic.string/nonnull.verify.cpp b/libcxx/test/libcxx/strings/basic.string/nonnull.verify.cpp
index d51ce1fcf2ba6..bf50ec37d7eea 100644
--- a/libcxx/test/libcxx/strings/basic.string/nonnull.verify.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/nonnull.verify.cpp
@@ -13,7 +13,7 @@
 // AppleClang doesn't have diagnose_if with diagnostic flags
 // UNSUPPORTED: apple-clang-21
 
-// ADDITIONAL_COMPILE_FLAGS: -Wno-unused-result
+// ADDITIONAL_COMPILE_FLAGS: -Wno-unused
 
 #include <string>
 
diff --git a/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp
index 9fd82f2e2ae7a..6213f32fb7a22 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.cons/constinit_sso_string.compile.pass.cpp
@@ -22,4 +22,4 @@
 #endif
 
 constinit std::string g_str = LONGEST_STR;
-void fn() { constexpr std::string l_str = LONGEST_STR; }
+void fn() { [[maybe_unused]] constexpr std::string l_str = LONGEST_STR; }
diff --git a/libcxx/test/std/containers/associative/from_range_associative_containers.h b/libcxx/test/std/containers/associative/from_range_associative_containers.h
index 943b79f5211fc..526848bc72c23 100644
--- a/libcxx/test/std/containers/associative/from_range_associative_containers.h
+++ b/libcxx/test/std/containers/associative/from_range_associative_containers.h
@@ -260,6 +260,7 @@ void test_set_exception_safety_throwing_copy() {
 
   try {
     Container<T> c(std::from_range, in);
+    (void)c;
     assert(false); // The constructor call above should throw.
 
   } catch (int) {
@@ -279,6 +280,7 @@ void test_set_exception_safety_throwing_allocator() {
 
     globalMemCounter.reset();
     Container<T, test_less<T>, ThrowingAllocator<T>> c(std::from_range, in, alloc);
+    (void)c;
     assert(false); // The constructor call above should throw.
 
   } catch (int) {
diff --git a/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp
index 939a23f240b52..42a594dcc1e44 100644
--- a/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp
@@ -33,6 +33,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
 
   // Make sure that the allocator isn't rebound to and incomplete type
   std::map<int, int, std::less<int>, complete_type_allocator<std::pair<const int, int> > > m;
+  (void)m;
 
   return true;
 }
diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.addressof.compile.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.addressof.compile.pass.cpp
index 9909ef841b875..da2c6ec1a10e6 100644
--- a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.addressof.compile.pass.cpp
@@ -24,10 +24,12 @@ void test() {
     std::map<int, operator_hijacker> mo;
     std::map<int, operator_hijacker> m;
     m = mo;
+    (void)m;
   }
   {
     std::map<operator_hijacker, int> mo;
     std::map<operator_hijacker, int> m;
     m = mo;
+    (void)m;
   }
 }
diff --git a/libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp
index 470275aea064b..c003b1b8e8089 100644
--- a/libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/incomplete_type.pass.cpp
@@ -31,6 +31,7 @@ int main(int, char**) {
 
   // Make sure that the allocator isn't rebound to and incomplete type
   std::multimap<int, int, std::less<int>, complete_type_allocator<std::pair<const int, int> > > m;
+  (void)m;
 
   return 0;
 }
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.addressof.compile.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.addressof.compile.pass.cpp
index 86288390af0e7..c737f9e214ded 100644
--- a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.addressof.compile.pass.cpp
@@ -24,10 +24,12 @@ void test() {
     std::multimap<int, operator_hijacker> mo;
     std::multimap<int, operator_hijacker> m;
     m = mo;
+    (void)m;
   }
   {
     std::multimap<operator_hijacker, int> mo;
     std::multimap<operator_hijacker, int> m;
     m = mo;
+    (void)m;
   }
 }
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.addressof.compile.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.addressof.compile.pass.cpp
index c91493ff0d62d..9f25db59a2fe0 100644
--- a/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.addressof.compile.pass.cpp
@@ -23,4 +23,5 @@ void test() {
   std::multiset<operator_hijacker> so;
   std::multiset<operator_hijacker> s;
   s = so;
+  (void)s;
 }
diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.addressof.compile.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.addressof.compile.pass.cpp
index e3677991a23dd..36c4a0ebce098 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.addressof.compile.pass.cpp
@@ -23,4 +23,5 @@ void test() {
   std::set<operator_hijacker> so;
   std::set<operator_hijacker> s;
   s = so;
+  (void)s;
 }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.compile.pass.cpp
similarity index 55%
rename from libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp
rename to libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.compile.pass.cpp
index 9fb6785a7cf1a..bb766891519f2 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.compile.pass.cpp
@@ -23,7 +23,6 @@
 #include <functional>
 #include <vector>
 
-#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -32,38 +31,12 @@ struct ThrowingCtorComp {
   constexpr bool operator()(const auto&, const auto&) const { return false; }
 };
 
-constexpr bool test() {
 #if defined(_LIBCPP_VERSION)
-  {
-    using C = std::flat_map<MoveOnly, MoveOnly>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C = std::flat_map<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
+static_assert(std::is_nothrow_default_constructible_v<std::flat_map<MoveOnly, MoveOnly>>);
+static_assert(std::is_nothrow_default_constructible_v<
+              std::flat_map<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>>);
 #endif // _LIBCPP_VERSION
-  {
-    using C = std::flat_map<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C = std::flat_map<MoveOnly, MoveOnly, ThrowingCtorComp>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-
-  return true;
-}
-
-int main(int, char**) {
-  test();
-#if TEST_STD_VER >= 26
-  static_assert(test());
-#endif
-
-  return 0;
-}
+static_assert(
+    !std::is_nothrow_default_constructible_v<
+        std::flat_map<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>>);
+static_assert(!std::is_nothrow_default_constructible_v<std::flat_map<MoveOnly, MoveOnly, ThrowingCtorComp>>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.compile.pass.cpp
similarity index 85%
rename from libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp
rename to libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.compile.pass.cpp
index 9e8198443387b..4e7897b0b9349 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.compile.pass.cpp
@@ -19,7 +19,6 @@
 #include <vector>
 #include <type_traits>
 
-#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -33,49 +32,28 @@ constexpr void test() {
   {
     using C = std::flat_map<MoveOnly, MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>, ValueContainer<MoveOnly>>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V  = KeyContainer<MoveOnly, test_allocator<MoveOnly>>;
     using V2 = ValueContainer<MoveOnly, test_allocator<MoveOnly>>;
     using C  = std::flat_map<MoveOnly, MoveOnly, std::less<MoveOnly>, V, V2>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V  = KeyContainer<MoveOnly, test_allocator<MoveOnly>>;
     using V2 = ValueContainer<MoveOnly, test_allocator<MoveOnly>>;
     using C  = std::flat_map<MoveOnly, MoveOnly, std::greater<MoveOnly>, V, V2>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #if defined(_LIBCPP_VERSION)
   {
     using C = std::flat_map<MoveOnly, MoveOnly, ThrowingDtorComp, KeyContainer<MoveOnly>, ValueContainer<MoveOnly>>;
     static_assert(!std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #endif // _LIBCPP_VERSION
 }
 
-constexpr bool test() {
+void test() {
   test<std::vector, std::vector>();
-
-#ifndef __cpp_lib_constexpr_deque
-  if (!TEST_IS_CONSTANT_EVALUATED)
-#endif
-  {
-    test<std::deque, std::deque>();
-  }
-
-  return true;
-}
-
-int main(int, char**) {
-  test();
-#if TEST_STD_VER >= 26
-  static_assert(test());
-#endif
-
-  return 0;
+  test<std::deque, std::deque>();
 }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
index e56cb12d9a113..822816bc3de0b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
@@ -52,6 +52,7 @@ int main(int, char**) {
     countdown = 1;
     try {
       M m = std::move(mo);
+      (void)m;
       assert(false); // not reached
     } catch (int x) {
       assert(x == 42);
@@ -66,6 +67,7 @@ int main(int, char**) {
     countdown = 1;
     try {
       M m = std::move(mo);
+      (void)m;
       assert(false); // not reached
     } catch (int x) {
       assert(x == 42);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.compile.pass.cpp
similarity index 60%
rename from libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp
rename to libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.compile.pass.cpp
index d281dafbcf72d..c524338cbff36 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.compile.pass.cpp
@@ -60,43 +60,18 @@ struct MoveSensitiveComp {
   bool is_moved_from_ = false;
 };
 
-int main(int, char**) {
-  {
-    using C = std::flat_map<int, int>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    using C = std::flat_map<int, int, std::less<int>, std::deque<int, test_allocator<int>>>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<std::flat_map<int, int>>);
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<
+                     std::flat_map<int, int, std::less<int>, std::deque<int, test_allocator<int>>>>);
 #if _LIBCPP_VERSION
-  {
-    // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
-    using C = std::flat_map<int, int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>, std::vector<int>>;
-    static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
-    using C = std::flat_map<int, int, std::less<int>, std::vector<int>, std::deque<int, ThrowingMoveAllocator<int>>>;
-    static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+// Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
+static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
+static_assert(!std::is_nothrow_move_constructible_v<
+              std::flat_map<int, int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>, std::vector<int>>>);
+// Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
+static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
+static_assert(!std::is_nothrow_move_constructible_v<
+              std::flat_map<int, int, std::less<int>, std::vector<int>, std::deque<int, ThrowingMoveAllocator<int>>>>);
 #endif // _LIBCPP_VERSION
-  {
-    // Comparator fails to be nothrow-move-constructible
-    using C = std::flat_map<int, int, ThrowingMoveComp>;
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  return 0;
-}
+// Comparator fails to be nothrow-move-constructible
+static_assert(!std::is_nothrow_move_constructible_v<std::flat_map<int, int, ThrowingMoveComp>>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/default_noexcept.compile.pass.cpp
similarity index 60%
rename from libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/default_noexcept.pass.cpp
rename to libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/default_noexcept.compile.pass.cpp
index 49df5561767a2..cd0d75bf04a62 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/default_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/default_noexcept.compile.pass.cpp
@@ -23,7 +23,6 @@
 #include <functional>
 #include <vector>
 
-#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -32,39 +31,13 @@ struct ThrowingCtorComp {
   constexpr bool operator()(const auto&, const auto&) const { return false; }
 };
 
-constexpr bool test() {
 #if defined(_LIBCPP_VERSION)
-  {
-    using C = std::flat_multimap<MoveOnly, MoveOnly>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C =
-        std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
+static_assert(std::is_nothrow_default_constructible_v<std::flat_multimap<MoveOnly, MoveOnly>>);
+static_assert(
+    std::is_nothrow_default_constructible_v<
+        std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>>);
 #endif // _LIBCPP_VERSION
-  {
-    using C =
-        std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C = std::flat_multimap<MoveOnly, MoveOnly, ThrowingCtorComp>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  return true;
-}
-
-int main(int, char**) {
-  test();
-#if TEST_STD_VER >= 26
-  static_assert(test());
-#endif
-
-  return 0;
-}
+static_assert(
+    !std::is_nothrow_default_constructible_v<
+        std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>>);
+static_assert(!std::is_nothrow_default_constructible_v<std::flat_multimap<MoveOnly, MoveOnly, ThrowingCtorComp>>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/dtor_noexcept.compile.pass.cpp
similarity index 86%
rename from libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/dtor_noexcept.pass.cpp
rename to libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/dtor_noexcept.compile.pass.cpp
index 2534a4748aa76..4286263bf31f4 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/dtor_noexcept.compile.pass.cpp
@@ -34,50 +34,29 @@ constexpr void test() {
     using C =
         std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>, ValueContainer<MoveOnly>>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V  = KeyContainer<MoveOnly, test_allocator<MoveOnly>>;
     using V2 = ValueContainer<MoveOnly, test_allocator<MoveOnly>>;
     using C  = std::flat_multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, V, V2>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V  = KeyContainer<MoveOnly, test_allocator<MoveOnly>>;
     using V2 = ValueContainer<MoveOnly, test_allocator<MoveOnly>>;
     using C  = std::flat_multimap<MoveOnly, MoveOnly, std::greater<MoveOnly>, V, V2>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #if defined(_LIBCPP_VERSION)
   {
     using C =
         std::flat_multimap<MoveOnly, MoveOnly, ThrowingDtorComp, KeyContainer<MoveOnly>, ValueContainer<MoveOnly>>;
     static_assert(!std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #endif // _LIBCPP_VERSION
 }
 
-constexpr bool test() {
+void test() {
   test<std::vector, std::vector>();
-
-#ifndef __cpp_lib_constexpr_deque
-  if (!TEST_IS_CONSTANT_EVALUATED)
-#endif
-  {
-    test<std::deque, std::deque>();
-  }
-
-  return true;
-}
-
-int main(int, char**) {
-  test();
-#if TEST_STD_VER >= 26
-  static_assert(test());
-#endif
-
-  return 0;
+  test<std::deque, std::deque>();
 }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp
index 44b6e93114c78..1140277880317 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_exceptions.pass.cpp
@@ -52,6 +52,7 @@ int main(int, char**) {
     countdown = 1;
     try {
       M m = std::move(mo);
+      (void)m;
       assert(false); // not reached
     } catch (int x) {
       assert(x == 42);
@@ -66,6 +67,7 @@ int main(int, char**) {
     countdown = 1;
     try {
       M m = std::move(mo);
+      (void)m;
       assert(false); // not reached
     } catch (int x) {
       assert(x == 42);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_noexcept.compile.pass.cpp
similarity index 63%
rename from libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_noexcept.pass.cpp
rename to libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_noexcept.compile.pass.cpp
index e038902e26d52..173874c918d0a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.cons/move_noexcept.compile.pass.cpp
@@ -26,7 +26,6 @@
 #include <vector>
 
 #include "test_macros.h"
-#include "MoveOnly.h"
 #include "test_allocator.h"
 
 template <class T>
@@ -60,45 +59,20 @@ struct MoveSensitiveComp {
   bool is_moved_from_ = false;
 };
 
-int main(int, char**) {
-  {
-    using C = std::flat_multimap<int, int>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    using C = std::flat_multimap<int, int, std::less<int>, std::deque<int, test_allocator<int>>>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<std::flat_multimap<int, int>>);
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<
+                     std::flat_multimap<int, int, std::less<int>, std::deque<int, test_allocator<int>>>>);
 #if _LIBCPP_VERSION
-  {
-    // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
-    using C =
-        std::flat_multimap<int, int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>, std::vector<int>>;
-    static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
-    using C =
-        std::flat_multimap<int, int, std::less<int>, std::vector<int>, std::deque<int, ThrowingMoveAllocator<int>>>;
-    static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+// Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
+static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
+static_assert(
+    !std::is_nothrow_move_constructible_v<
+        std::flat_multimap<int, int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>, std::vector<int>>>);
+// Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
+static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
+static_assert(
+    !std::is_nothrow_move_constructible_v<
+        std::flat_multimap<int, int, std::less<int>, std::vector<int>, std::deque<int, ThrowingMoveAllocator<int>>>>);
 #endif // _LIBCPP_VERSION
-  {
-    // Comparator fails to be nothrow-move-constructible
-    using C = std::flat_multimap<int, int, ThrowingMoveComp>;
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  return 0;
-}
+// Comparator fails to be nothrow-move-constructible
+static_assert(!std::is_nothrow_move_constructible_v<std::flat_multimap<int, int, ThrowingMoveComp>>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multimap/robust_against_nonbool.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multimap/robust_against_nonbool.compile.pass.cpp
index d5e2832390f53..78ac8f06d7eee 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multimap/robust_against_nonbool.compile.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multimap/robust_against_nonbool.compile.pass.cpp
@@ -25,7 +25,9 @@ void test() {
   std::flat_multimap<Key, Value> m1;
   std::flat_multimap m2(std::from_range, m1, StrictBinaryPredicate);
   std::flat_multimap m3(std::sorted_equivalent, m1.keys(), m1.values(), StrictBinaryPredicate);
+  (void)m3;
   std::flat_multimap m4(m1.begin(), m1.end(), StrictBinaryPredicate);
+  (void)m4;
   m2.insert(m1.begin(), m1.end());
   m2.insert(std::sorted_equivalent, m1.begin(), m1.end());
   m2.insert_range(m1);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp
index 3a7ff86c6c040..13c38f0c2fd56 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/default.pass.cpp
@@ -67,27 +67,14 @@ constexpr void test() {
     }
   }
 #if defined(_LIBCPP_VERSION)
-  {
-    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, test_allocator<MoveOnly>>>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
+  static_assert(std::is_nothrow_default_constructible_v<std::flat_multiset<MoveOnly, std::less<MoveOnly>>>);
+  static_assert(std::is_nothrow_default_constructible_v<
+                std::flat_multiset<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, test_allocator<MoveOnly>>>>);
 #endif // _LIBCPP_VERSION
-  {
-    using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, other_allocator<MoveOnly>>>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C = std::flat_multiset<MoveOnly, ThrowingCtorComp, KeyContainer<MoveOnly>>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
+  static_assert(!std::is_nothrow_default_constructible_v<
+                std::flat_multiset<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, other_allocator<MoveOnly>>>>);
+  static_assert(
+      !std::is_nothrow_default_constructible_v<std::flat_multiset<MoveOnly, ThrowingCtorComp, KeyContainer<MoveOnly>>>);
 }
 
 constexpr bool test() {
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp
index 0df06672a6ba3..98942ffc60f9c 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/dtor_noexcept.pass.cpp
@@ -33,25 +33,21 @@ constexpr void test() {
   {
     using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V = KeyContainer<MoveOnly, test_allocator<MoveOnly>>;
     using C = std::flat_multiset<MoveOnly, std::less<MoveOnly>, V>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V = KeyContainer<MoveOnly, other_allocator<MoveOnly>>;
     using C = std::flat_multiset<MoveOnly, std::greater<MoveOnly>, V>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #if defined(_LIBCPP_VERSION)
   {
     using C = std::flat_multiset<MoveOnly, ThrowingDtorComp, KeyContainer<MoveOnly>>;
     static_assert(!std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #endif // _LIBCPP_VERSION
 }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
index f9fea737254d3..5a1d53e20ac8d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.cons/move.pass.cpp
@@ -124,34 +124,16 @@ struct MoveSensitiveComp {
 };
 
 void test_move_noexcept() {
-  {
-    using C = std::flat_multiset<int>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    using C = std::flat_multiset<int, std::less<int>, std::deque<int, test_allocator<int>>>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+  LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<std::flat_multiset<int>>);
+  LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<
+                       std::flat_multiset<int, std::less<int>, std::deque<int, test_allocator<int>>>>);
 #if _LIBCPP_VERSION
-  {
-    // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
-    using C = std::flat_multiset<int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>>;
-    static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    // Comparator fails to be nothrow-move-constructible
-    using C = std::flat_multiset<int, ThrowingMoveComp>;
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+  // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
+  static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
+  static_assert(!std::is_nothrow_move_constructible_v<
+                std::flat_multiset<int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>>>);
+  // Comparator fails to be nothrow-move-constructible
+  static_assert(!std::is_nothrow_move_constructible_v<std::flat_multiset<int, ThrowingMoveComp>>);
 #endif // _LIBCPP_VERSION
 }
 
@@ -184,6 +166,7 @@ void test_move_exception() {
     countdown = 1;
     try {
       M m = std::move(mo);
+      (void)m;
       assert(false); // not reached
     } catch (int x) {
       assert(x == 42);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.multiset/robust_against_nonbool.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.multiset/robust_against_nonbool.compile.pass.cpp
index e312ec6766218..851eba6e6ac56 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.multiset/robust_against_nonbool.compile.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.multiset/robust_against_nonbool.compile.pass.cpp
@@ -26,6 +26,7 @@ void test() {
   std::flat_multiset m2(std::from_range, v, StrictBinaryPredicate);
   std::flat_multiset m3(std::sorted_equivalent, v, StrictBinaryPredicate);
   std::flat_multiset m4(m1.begin(), m1.end(), StrictBinaryPredicate);
+  (void)m4;
   m2.insert(m1.begin(), m1.end());
   m2.insert(std::sorted_equivalent, m1.begin(), m1.end());
   m2.insert_range(m1);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp
index 75eba28b61bd5..3cf976039a0ad 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp
@@ -67,27 +67,15 @@ constexpr void test() {
     }
   }
 #if defined(_LIBCPP_VERSION)
-  {
-    using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, test_allocator<MoveOnly>>>;
-    static_assert(std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
+  static_assert(
+      std::is_nothrow_default_constructible_v<std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>>>);
+  static_assert(std::is_nothrow_default_constructible_v<
+                std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, test_allocator<MoveOnly>>>>);
 #endif // _LIBCPP_VERSION
-  {
-    using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, other_allocator<MoveOnly>>>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
-  {
-    using C = std::flat_set<MoveOnly, ThrowingCtorComp, KeyContainer<MoveOnly>>;
-    static_assert(!std::is_nothrow_default_constructible_v<C>);
-    C c;
-  }
+  static_assert(!std::is_nothrow_default_constructible_v<
+                std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, other_allocator<MoveOnly>>>>);
+  static_assert(
+      !std::is_nothrow_default_constructible_v<std::flat_set<MoveOnly, ThrowingCtorComp, KeyContainer<MoveOnly>>>);
 }
 
 constexpr bool test() {
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp
index 1caf58fff72d3..3e46f7d6c171b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp
@@ -33,25 +33,21 @@ constexpr void test() {
   {
     using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V = KeyContainer<MoveOnly, test_allocator<MoveOnly>>;
     using C = std::flat_set<MoveOnly, std::less<MoveOnly>, V>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
   {
     using V = KeyContainer<MoveOnly, other_allocator<MoveOnly>>;
     using C = std::flat_set<MoveOnly, std::greater<MoveOnly>, V>;
     static_assert(std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #if defined(_LIBCPP_VERSION)
   {
     using C = std::flat_set<MoveOnly, ThrowingDtorComp, KeyContainer<MoveOnly>>;
     static_assert(!std::is_nothrow_destructible_v<C>);
-    C c;
   }
 #endif // _LIBCPP_VERSION
 }
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
index 1d7a3589cc109..47e4ae7086206 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
@@ -102,34 +102,16 @@ struct ThrowingMoveComp {
 
 template <template <class...> class KeyContainer>
 constexpr void test_move_noexcept() {
-  {
-    using C = std::flat_set<int, std::less<int>, KeyContainer<int>>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    using C = std::flat_set<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
-    LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+  LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<std::flat_set<int, std::less<int>, KeyContainer<int>>>);
+  LIBCPP_STATIC_ASSERT(
+      std::is_nothrow_move_constructible_v<std::flat_set<int, std::less<int>, KeyContainer<int, test_allocator<int>>>>);
 #if _LIBCPP_VERSION
-  if (!TEST_IS_CONSTANT_EVALUATED) {
-    // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
-    using C = std::flat_set<int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>>;
-    static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
-  {
-    // Comparator fails to be nothrow-move-constructible
-    using C = std::flat_set<int, ThrowingMoveComp, KeyContainer<int>>;
-    static_assert(!std::is_nothrow_move_constructible_v<C>);
-    C c;
-    C d = std::move(c);
-  }
+  // Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
+  static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
+  static_assert(!std::is_nothrow_move_constructible_v<
+                std::flat_set<int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>>>);
+  // Comparator fails to be nothrow-move-constructible
+  static_assert(!std::is_nothrow_move_constructible_v<std::flat_set<int, ThrowingMoveComp, KeyContainer<int>>>);
 #endif // _LIBCPP_VERSION
 }
 
@@ -175,6 +157,7 @@ void test_move_exception() {
     countdown = 1;
     try {
       M m = std::move(mo);
+      (void)m;
       assert(false); // not reached
     } catch (int x) {
       assert(x == 42);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/robust_against_nonbool.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/robust_against_nonbool.compile.pass.cpp
index 84f96d38ed3fa..b96d7f55ff8d0 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/robust_against_nonbool.compile.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/robust_against_nonbool.compile.pass.cpp
@@ -26,6 +26,7 @@ void test() {
   std::flat_set m2(std::from_range, v, StrictBinaryPredicate);
   std::flat_set m3(std::sorted_unique, v, StrictBinaryPredicate);
   std::flat_set m4(m1.begin(), m1.end(), StrictBinaryPredicate);
+  (void)m4;
   m2.insert(m1.begin(), m1.end());
   m2.insert(std::sorted_unique, m1.begin(), m1.end());
   m2.insert_range(m1);
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.addressof.compile.pass.cpp
index 7b2326824bf09..6222df91ad741 100644
--- a/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.addressof.compile.pass.cpp
@@ -21,4 +21,5 @@ void test() {
   std::deque<operator_hijacker> dqo;
   std::deque<operator_hijacker> dq;
   dq = dqo;
+  (void)dq;
 }
diff --git a/libcxx/test/std/containers/sequences/forwardlist/exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/exception_safety.pass.cpp
index a345665634276..a6b8892d7d875 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/exception_safety.pass.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/exception_safety.pass.cpp
@@ -213,12 +213,14 @@ int main(int, char**) {
     // forward_list& operator=(const forward_list& x);
     test_exception_safety_throwing_copy_container<C, ThrowOn, Size>([](C&& in) {
       std::forward_list<T> c;
+      (void)c;
       c = in;
     });
 
     // forward_list& operator=(initializer_list<value_type> il);
     test_exception_safety_throwing_copy<ThrowOn, Size>([&il](T*, T*) {
       std::forward_list<T> c;
+      (void)c;
       c = il;
     });
 
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.addressof.compile.pass.cpp
index ef2d38114d91c..bccc730696b9d 100644
--- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.addressof.compile.pass.cpp
@@ -21,4 +21,5 @@ void test() {
   std::forward_list<operator_hijacker> lo;
   std::forward_list<operator_hijacker> l;
   l = lo;
+  (void)l;
 }
diff --git a/libcxx/test/std/containers/sequences/from_range_sequence_containers.h b/libcxx/test/std/containers/sequences/from_range_sequence_containers.h
index 0d04d26ef3c31..a44fcf0b4452f 100644
--- a/libcxx/test/std/containers/sequences/from_range_sequence_containers.h
+++ b/libcxx/test/std/containers/sequences/from_range_sequence_containers.h
@@ -136,6 +136,7 @@ void test_exception_safety_throwing_allocator() {
 
     globalMemCounter.reset();
     Container<T, ThrowingAllocator<T>> c(std::from_range, in, alloc);
+    (void)c;
     assert(false); // The constructor call above should throw.
 
   } catch (int) {
diff --git a/libcxx/test/std/containers/sequences/list/exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/list/exception_safety.pass.cpp
index 9820792f748c2..5c78c6ef23c31 100644
--- a/libcxx/test/std/containers/sequences/list/exception_safety.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/exception_safety.pass.cpp
@@ -150,6 +150,7 @@ int main(int, char**) {
     // list& operator=(const list& x);
     test_exception_safety_throwing_copy_container<C, ThrowOn, Size>([](C&& in) {
       std::list<T> c;
+      (void)c;
       c = in;
     });
 
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.addressof.compile.pass.cpp
index 4d183b16154db..7b38f8fd9a3d9 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.addressof.compile.pass.cpp
@@ -21,4 +21,5 @@ void test() {
   std::list<operator_hijacker> lo;
   std::list<operator_hijacker> l;
   l = lo;
+  (void)l;
 }
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_move.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_move.addressof.compile.pass.cpp
index a305587ca91f0..f5c5edfe8f263 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/assign_move.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_move.addressof.compile.pass.cpp
@@ -23,4 +23,5 @@ void test() {
   std::list<operator_hijacker> lo;
   std::list<operator_hijacker> l;
   l = std::move(lo);
+  (void)l;
 }
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
index d92307283098d..8fef2f6f10e9f 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
@@ -184,10 +184,12 @@ void test_ctor_under_alloc() {
     {
       ExpectConstructGuard<int&> G(1);
       C v(It(arr1), It(std::end(arr1)));
+      (void)v;
     }
     {
       ExpectConstructGuard<int&> G(3);
       C v(It(arr2), It(std::end(arr2)));
+      (void)v;
     }
   }
   {
@@ -196,10 +198,12 @@ void test_ctor_under_alloc() {
     {
       ExpectConstructGuard<int&> G(1);
       C v(It(arr1), It(std::end(arr1)));
+      (void)v;
     }
     {
       ExpectConstructGuard<int&> G(3);
       C v(It(arr2), It(std::end(arr2)));
+      (void)v;
     }
   }
 #endif
@@ -217,10 +221,12 @@ void test_ctor_under_alloc_with_alloc() {
     {
       ExpectConstructGuard<int&> G(1);
       C v(It(arr1), It(std::end(arr1)), a);
+      (void)v;
     }
     {
       ExpectConstructGuard<int&> G(3);
       C v(It(arr2), It(std::end(arr2)), a);
+      (void)v;
     }
   }
   {
diff --git a/libcxx/test/std/containers/sequences/vector.bool/ctor_exceptions.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/ctor_exceptions.pass.cpp
index cb2b7d124edc1..a39c06b34fcdf 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/ctor_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/ctor_exceptions.pass.cpp
@@ -25,6 +25,7 @@ int main(int, char**) {
 
   try { // Throw in vector() from allocator
     AllocVec vec;
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -33,6 +34,7 @@ int main(int, char**) {
   try { // Throw in vector(size_type, const allocator_type&) from allocator
     throwing_allocator<bool> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec get_alloc(0, alloc);
+    (void)get_alloc;
   } catch (int) {
   }
   check_new_delete_called();
@@ -41,6 +43,7 @@ int main(int, char**) {
   try { // Throw in vector(size_type, const value_type&, const allocator_type&) from allocator
     throwing_allocator<bool> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec get_alloc(0, true, alloc);
+    (void)get_alloc;
   } catch (int) {
   }
   check_new_delete_called();
@@ -48,6 +51,7 @@ int main(int, char**) {
   try { // Throw in vector(InputIterator, InputIterator) from input iterator
     std::vector<bool> vec(
         throwing_iterator<bool, std::input_iterator_tag>(), throwing_iterator<bool, std::input_iterator_tag>(2));
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -55,6 +59,7 @@ int main(int, char**) {
   try { // Throw in vector(InputIterator, InputIterator) from forward iterator
     std::vector<bool> vec(
         throwing_iterator<bool, std::forward_iterator_tag>(), throwing_iterator<bool, std::forward_iterator_tag>(2));
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -62,6 +67,7 @@ int main(int, char**) {
   try { // Throw in vector(InputIterator, InputIterator) from allocator
     bool a[] = {true, true};
     AllocVec vec(cpp17_input_iterator<bool*>(a), cpp17_input_iterator<bool*>(a + 2));
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -70,6 +76,7 @@ int main(int, char**) {
     std::allocator<bool> alloc;
     std::vector<bool> vec(
         throwing_iterator<bool, std::input_iterator_tag>(), throwing_iterator<bool, std::input_iterator_tag>(2), alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -79,6 +86,7 @@ int main(int, char**) {
     std::vector<bool> vec(throwing_iterator<bool, std::forward_iterator_tag>(),
                           throwing_iterator<bool, std::forward_iterator_tag>(2),
                           alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -87,6 +95,7 @@ int main(int, char**) {
     bool a[] = {true, false};
     throwing_allocator<bool> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec vec(cpp17_input_iterator<bool*>(a), cpp17_input_iterator<bool*>(a + 2), alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -95,6 +104,7 @@ int main(int, char**) {
     bool a[] = {true, false};
     throwing_allocator<bool> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec vec(forward_iterator<bool*>(a), forward_iterator<bool*>(a + 2), alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -106,6 +116,7 @@ int main(int, char**) {
     vec.push_back(true);
     alloc.throw_on_copy_ = true;
     AllocVec vec2(vec, alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -116,6 +127,7 @@ int main(int, char**) {
     vec.push_back(true);
     alloc.throw_on_copy_ = true;
     AllocVec vec2(std::move(vec), alloc);
+    (void)vec2;
   } catch (int) {
   }
   check_new_delete_called();
@@ -123,6 +135,7 @@ int main(int, char**) {
   try { // Throw in vector(initializer_list<value_type>, const allocator_type&) constructor from allocator
     throwing_allocator<bool> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec vec({true, true}, alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
diff --git a/libcxx/test/std/containers/sequences/vector/addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/addressof.compile.pass.cpp
index 86f8d0e17e665..01934f31e590c 100644
--- a/libcxx/test/std/containers/sequences/vector/addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/addressof.compile.pass.cpp
@@ -41,9 +41,11 @@ void test(
   // construction
   {
     Vector v2(std::move(v));
+    (void)v2;
   }
   {
     Vector v2(std::move(v), std::allocator<operator_hijacker>());
+    (void)v2;
   }
 
   // swap
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
index 51da5d2d2ca4d..3556b1c4d4524 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -83,7 +83,9 @@ TEST_CONSTEXPR_CXX20 void basic_test_cases() {
   // Regression test for https://llvm.org/PR47497
   {
     std::vector<int> v1({}, forward_iterator<const int*>{});
+    (void)v1;
     std::vector<int> v2(forward_iterator<const int*>{}, {});
+    (void)v2;
   }
 #endif
 }
@@ -137,10 +139,12 @@ void test_ctor_under_alloc() {
     {
       ExpectConstructGuard<int&> G(1);
       C v(It(arr1), It(std::end(arr1)));
+      (void)v;
     }
     {
       ExpectConstructGuard<int&> G(3);
       C v(It(arr2), It(std::end(arr2)));
+      (void)v;
     }
   }
   {
@@ -149,6 +153,7 @@ void test_ctor_under_alloc() {
     {
       ExpectConstructGuard<int&> G(1);
       C v(It(arr1), It(std::end(arr1)));
+      (void)v;
     }
     {
       //ExpectConstructGuard<int&> G(3);
@@ -163,11 +168,13 @@ void test_ctor_under_alloc() {
     {
       Alloc::construct_called = false;
       C v(arr1, arr1 + 1);
+      (void)v;
       assert(Alloc::construct_called);
     }
     {
       Alloc::construct_called = false;
       C v(arr2, arr2 + 3);
+      (void)v;
       assert(Alloc::construct_called);
     }
   }
@@ -177,11 +184,13 @@ void test_ctor_under_alloc() {
     {
       Alloc::construct_called = false;
       C v(arr1, arr1 + 1);
+      (void)v;
       assert(Alloc::construct_called);
     }
     {
       Alloc::construct_called = false;
       C v(arr2, arr2 + 3);
+      (void)v;
       assert(Alloc::construct_called);
     }
   }
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
index 56a3778ddf965..0a711066f38ff 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -94,7 +94,9 @@ TEST_CONSTEXPR_CXX20 void basic_tests() {
   {
     min_allocator<int> alloc;
     std::vector<int, min_allocator<int> > v1({}, forward_iterator<const int*>{}, alloc);
+    (void)v1;
     std::vector<int, min_allocator<int> > v2(forward_iterator<const int*>{}, {}, alloc);
+    (void)v2;
   }
 #endif
 }
@@ -152,10 +154,12 @@ void test_ctor_under_alloc() {
     {
       ExpectConstructGuard<int&> G(1);
       C v(It(arr1), It(std::end(arr1)), a);
+      (void)v;
     }
     {
       ExpectConstructGuard<int&> G(3);
       C v(It(arr2), It(std::end(arr2)), a);
+      (void)v;
     }
   }
   {
@@ -166,6 +170,7 @@ void test_ctor_under_alloc() {
     {
       ExpectConstructGuard<int&> G(1);
       C v(It(arr1), It(std::end(arr1)), a);
+      (void)v;
     }
     {
       //ExpectConstructGuard<int&> G(3);
@@ -181,11 +186,13 @@ void test_ctor_under_alloc() {
     {
       Alloc::construct_called = false;
       C v(arr1, arr1 + 1, a);
+      (void)v;
       assert(Alloc::construct_called);
     }
     {
       Alloc::construct_called = false;
       C v(arr2, arr2 + 3, a);
+      (void)v;
       assert(Alloc::construct_called);
     }
   }
@@ -196,11 +203,13 @@ void test_ctor_under_alloc() {
     {
       Alloc::construct_called = false;
       C v(arr1, arr1 + 1, a);
+      (void)v;
       assert(Alloc::construct_called);
     }
     {
       Alloc::construct_called = false;
       C v(arr2, arr2 + 3, a);
+      (void)v;
       assert(Alloc::construct_called);
     }
   }
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp
index 679eec2413793..c2408a81ead88 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp
@@ -25,12 +25,14 @@ int main(int, char**) {
   using AllocVec = std::vector<int, throwing_allocator<int> >;
   try { // vector()
     AllocVec vec;
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
 
   try { // Throw in vector(size_type) from type
     std::vector<throwing_t> get_alloc(1);
+    (void)get_alloc;
   } catch (int) {
   }
   check_new_delete_called();
@@ -40,6 +42,7 @@ int main(int, char**) {
     int throw_after = 1;
     throwing_t v(throw_after);
     std::vector<throwing_t> get_alloc(1, v);
+    (void)get_alloc;
   } catch (int) {
   }
   check_new_delete_called();
@@ -47,12 +50,14 @@ int main(int, char**) {
   try { // Throw in vector(size_type, const allocator_type&) from allocator
     throwing_allocator<int> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec get_alloc(0, alloc);
+    (void)get_alloc;
   } catch (int) {
   }
   check_new_delete_called();
 
   try { // Throw in vector(size_type, const allocator_type&) from the type
     std::vector<throwing_t> vec(1, std::allocator<throwing_t>());
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -62,6 +67,7 @@ int main(int, char**) {
     int throw_after = 1;
     throwing_t v(throw_after);
     std::vector<throwing_t> vec(1, v, std::allocator<throwing_t>());
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -69,6 +75,7 @@ int main(int, char**) {
   try { // Throw in vector(InputIterator, InputIterator) from input iterator
     std::vector<int> vec(
         (throwing_iterator<int, std::input_iterator_tag>()), throwing_iterator<int, std::input_iterator_tag>(2));
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -76,6 +83,7 @@ int main(int, char**) {
   try { // Throw in vector(InputIterator, InputIterator) from forward iterator
     std::vector<int> vec(
         (throwing_iterator<int, std::forward_iterator_tag>()), throwing_iterator<int, std::forward_iterator_tag>(2));
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -83,6 +91,7 @@ int main(int, char**) {
   try { // Throw in vector(InputIterator, InputIterator) from allocator
     int a[] = {1, 2};
     AllocVec vec(cpp17_input_iterator<int*>(a), cpp17_input_iterator<int*>(a + 2));
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -91,6 +100,7 @@ int main(int, char**) {
     std::allocator<int> alloc;
     std::vector<int> vec(
         throwing_iterator<int, std::input_iterator_tag>(), throwing_iterator<int, std::input_iterator_tag>(2), alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -100,6 +110,7 @@ int main(int, char**) {
     std::vector<int> vec(throwing_iterator<int, std::forward_iterator_tag>(),
                          throwing_iterator<int, std::forward_iterator_tag>(2),
                          alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -108,6 +119,7 @@ int main(int, char**) {
     int a[] = {1, 2};
     throwing_allocator<int> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec vec(cpp17_input_iterator<int*>(a), cpp17_input_iterator<int*>(a + 2), alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -116,6 +128,7 @@ int main(int, char**) {
     int a[] = {1, 2};
     throwing_allocator<int> alloc(/*throw_on_ctor = */ false, /*throw_on_copy = */ true);
     AllocVec vec(forward_iterator<int*>(a), forward_iterator<int*>(a + 2), alloc);
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -125,6 +138,7 @@ int main(int, char**) {
     int throw_after = 1;
     vec.emplace_back(throw_after);
     auto vec2 = vec;
+    (void)vec2;
   } catch (int) {
   }
   check_new_delete_called();
@@ -134,6 +148,7 @@ int main(int, char**) {
     int throw_after = 1;
     vec.emplace_back(throw_after);
     std::vector<throwing_t> vec2(vec, std::allocator<int>());
+    (void)vec2;
   } catch (int) {
   }
   check_new_delete_called();
@@ -144,6 +159,7 @@ int main(int, char**) {
     throwing_t v(throw_after);
     vec.insert(vec.end(), 6, v);
     std::vector<throwing_t, test_allocator<throwing_t> > vec2(std::move(vec), test_allocator<throwing_t>(2));
+    (void)vec2;
   } catch (int) {
   }
   check_new_delete_called();
@@ -152,6 +168,7 @@ int main(int, char**) {
   try { // Throw in vector(initializer_list<value_type>) from type
     int throw_after = 1;
     std::vector<throwing_t> vec({throwing_t(throw_after)});
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
@@ -159,6 +176,7 @@ int main(int, char**) {
   try { // Throw in vector(initializer_list<value_type>, const allocator_type&) constructor from type
     int throw_after = 1;
     std::vector<throwing_t> vec({throwing_t(throw_after)}, std::allocator<throwing_t>());
+    (void)vec;
   } catch (int) {
   }
   check_new_delete_called();
diff --git a/libcxx/test/std/containers/unord/from_range_unordered_containers.h b/libcxx/test/std/containers/unord/from_range_unordered_containers.h
index b8aa73383354d..a36f039507fe1 100644
--- a/libcxx/test/std/containers/unord/from_range_unordered_containers.h
+++ b/libcxx/test/std/containers/unord/from_range_unordered_containers.h
@@ -225,6 +225,7 @@ void test_map_exception_safety_throwing_copy() {
 
   try {
     Container<K, V> c(std::from_range, in);
+    (void)c;
     assert(false); // The constructor call above should throw.
 
   } catch (int) {
@@ -246,6 +247,7 @@ void test_map_exception_safety_throwing_allocator() {
     globalMemCounter.reset();
     Container<K, V, test_hash<K>, test_equal_to<K>, ThrowingAllocator<ValueType>> c(
         std::from_range, in, /*n=*/0, alloc);
+    (void)c;
     assert(false); // The constructor call should throw.
 
   } catch (int) {
@@ -417,6 +419,7 @@ void test_set_exception_safety_throwing_copy() {
 
   try {
     Container<T, test_hash<T>> c(std::from_range, in);
+    (void)c;
     assert(false); // The constructor call above should throw.
 
   } catch (int) {
diff --git a/libcxx/test/std/containers/unord/unord.map/incomplete_type.pass.cpp b/libcxx/test/std/containers/unord/unord.map/incomplete_type.pass.cpp
index ba5e7e821b755..6ae865aa044d5 100644
--- a/libcxx/test/std/containers/unord/unord.map/incomplete_type.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/incomplete_type.pass.cpp
@@ -40,6 +40,7 @@ int main(int, char**) {
   // Make sure that the allocator isn't rebound to an incomplete type
   std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, complete_type_allocator<std::pair<const int, int> > >
       m;
+  (void)m;
 
   return 0;
 }
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.addressof.compile.pass.cpp
index d0013594b1136..7ae8190048f55 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.addressof.compile.pass.cpp
@@ -26,10 +26,12 @@ void test() {
     std::unordered_map<int, operator_hijacker> mo;
     std::unordered_map<int, operator_hijacker> m;
     m = mo;
+    (void)m;
   }
   {
     std::unordered_map<operator_hijacker, int> mo;
     std::unordered_map<operator_hijacker, int> m;
     m = mo;
+    (void)m;
   }
 }
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.addressof.compile.pass.cpp
index 6dbd7aaea2a8e..b3bf2ff112d44 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.addressof.compile.pass.cpp
@@ -33,10 +33,12 @@ void test() {
     std::unordered_map<int, operator_hijacker> mo;
     std::unordered_map<int, operator_hijacker> m;
     m = std::move(mo);
+    (void)m;
   }
   {
     std::unordered_map<operator_hijacker, int> mo;
     std::unordered_map<operator_hijacker, int> m;
     m = std::move(mo);
+    (void)m;
   }
 }
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.addressof.compile.pass.cpp
index e36c6525d631b..12d8aabfff5cb 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.addressof.compile.pass.cpp
@@ -30,4 +30,5 @@
 void test() {
   std::unordered_map<operator_hijacker, operator_hijacker> mo;
   std::unordered_map<operator_hijacker, operator_hijacker> m(std::move(mo));
+  (void)m;
 }
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.addressof.compile.pass.cpp
index 90c69b3855fab..1c4fc25716dd0 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.addressof.compile.pass.cpp
@@ -37,4 +37,5 @@ void test() {
 
   C mo;
   C m(std::move(mo), A());
+  (void)m;
 }
diff --git a/libcxx/test/std/containers/unord/unord.multimap/incomplete.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/incomplete.pass.cpp
index 5a9855765daf9..176135b32175d 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/incomplete.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/incomplete.pass.cpp
@@ -44,6 +44,7 @@ int main(int, char**) {
                           std::equal_to<int>,
                           complete_type_allocator<std::pair<const int, int> > >
       m;
+  (void)m;
 
   return 0;
 }
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.addressof.compile.pass.cpp
index ddb3a5d187cab..49328934474d7 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.addressof.compile.pass.cpp
@@ -26,10 +26,12 @@ void test() {
     std::unordered_multimap<int, operator_hijacker> mo;
     std::unordered_multimap<int, operator_hijacker> m;
     m = mo;
+    (void)m;
   }
   {
     std::unordered_multimap<operator_hijacker, int> mo;
     std::unordered_multimap<operator_hijacker, int> m;
     m = mo;
+    (void)m;
   }
 }
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.addressof.compile.pass.cpp
index 73b19f35e2048..33f1a48d450d5 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.addressof.compile.pass.cpp
@@ -30,4 +30,5 @@
 void test() {
   std::unordered_multimap<operator_hijacker, operator_hijacker> mo;
   std::unordered_multimap<operator_hijacker, operator_hijacker> m(std::move(mo));
+  (void)m;
 }
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.addressof.compile.pass.cpp
index 53c5179242949..7a11a3c446964 100644
--- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.addressof.compile.pass.cpp
@@ -37,4 +37,5 @@ void test() {
 
   C mo;
   C m(std::move(mo), A());
+  (void)m;
 }
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.addressof.compile.pass.cpp
index e167c7ad4186d..25ef805c13d04 100644
--- a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.addressof.compile.pass.cpp
@@ -25,4 +25,5 @@ void test() {
   std::unordered_multiset<operator_hijacker> so;
   std::unordered_multiset<operator_hijacker> s;
   s = so;
+  (void)s;
 }
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.addressof.compile.pass.cpp
index 9df029e61341a..ba2d3d0e5970f 100644
--- a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.addressof.compile.pass.cpp
@@ -26,4 +26,5 @@
 void test() {
   std::unordered_multiset<operator_hijacker> so;
   std::unordered_multiset<operator_hijacker> s(std::move(so));
+  (void)s;
 }
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.addressof.compile.pass.cpp
index cd1f70eab9e68..8724c4f8425bc 100644
--- a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.addressof.compile.pass.cpp
@@ -30,4 +30,5 @@ void test() {
   const A a;
   std::unordered_multiset<operator_hijacker, H, P, A> so;
   std::unordered_multiset<operator_hijacker, H, P, A> s(std::move(so), a);
+  (void)s;
 }
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.addressof.compile.pass.cpp
index de2784eeee672..0fb915f3af44f 100644
--- a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.addressof.compile.pass.cpp
@@ -25,4 +25,5 @@ void test() {
   std::unordered_set<operator_hijacker> so;
   std::unordered_set<operator_hijacker> s;
   s = so;
+  (void)s;
 }
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.addressof.compile.pass.cpp
index f7e9eb444bd58..52e4c3141d9d2 100644
--- a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.addressof.compile.pass.cpp
@@ -26,4 +26,5 @@
 void test() {
   std::unordered_set<operator_hijacker> so;
   std::unordered_set<operator_hijacker> s(std::move(so));
+  (void)s;
 }
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.addressof.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.addressof.compile.pass.cpp
index 8e9d8cb8d87b2..b3a20eb2102ab 100644
--- a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.addressof.compile.pass.cpp
@@ -32,4 +32,5 @@ void test() {
   const A a;
   std::unordered_set<operator_hijacker, H, P, A> so;
   std::unordered_set<operator_hijacker, H, P, A> s(std::move(so), a);
+  (void)s;
 }
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
index d15276b440157..8371588672450 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
@@ -22,16 +22,20 @@ int main(int, char**)
 {
     {
         std::fstream fs;
+        (void)fs;
     }
     {
       std::basic_fstream<char, operator_hijacker_char_traits<char> > fs;
+        (void)fs;
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
     {
         std::wfstream fs;
+        (void)fs;
     }
     {
       std::basic_fstream<wchar_t, operator_hijacker_char_traits<wchar_t> > fs;
+        (void)fs;
     }
 #endif
 
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
index 70d1efca20c65..d10d2cf62c525 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
@@ -22,16 +22,20 @@ int main(int, char**)
 {
     {
         std::ifstream fs;
+        (void)fs;
     }
     {
       std::basic_ifstream<char, operator_hijacker_char_traits<char> > fs;
+      (void)fs;
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
     {
         std::wifstream fs;
+        (void)fs;
     }
     {
       std::basic_ifstream<wchar_t, operator_hijacker_char_traits<wchar_t> > fs;
+      (void)fs;
     }
 #endif
 
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
index b1ff8ff63ca86..49e1a2505ce27 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ifstream.cons/path.pass.cpp
@@ -61,7 +61,6 @@ static_assert(test_non_convert_to_path<char32_t>());
 
 int main(int, char**) {
   {
-    fs::path p;
     static_assert(!std::is_convertible<fs::path, std::ifstream>::value,
                   "ctor should be explicit");
     static_assert(std::is_constructible<std::ifstream, fs::path const&,
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
index a7b0918f79365..1c0717ccae3b1 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
+++ b/libcxx/test/std/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
@@ -22,16 +22,20 @@ int main(int, char**)
 {
     {
         std::ofstream fs;
+        (void)fs;
     }
     {
       std::basic_ofstream<char, operator_hijacker_char_traits<char> > fs;
+      (void)fs;
     }
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
     {
         std::wofstream fs;
+        (void)fs;
     }
     {
       std::basic_fstream<wchar_t, operator_hijacker_char_traits<wchar_t> > fs;
+      (void)fs;
     }
 #endif
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy.pass.cpp
index 719c231d33e75..43d2408040a3e 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy.pass.cpp
@@ -44,7 +44,7 @@ static void copy_ctor() {
 static void copy_ctor_copies_cache() {
   using namespace fs;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path sym = env.create_symlink("dir/file", "sym");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy_assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy_assign.pass.cpp
index e897676ec2bfe..d2bad8ecfa90d 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/copy_assign.pass.cpp
@@ -50,7 +50,7 @@ static void test_copy_assign_operator() {
 static void copy_assign_copies_cache() {
   using namespace fs;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path sym = env.create_symlink("dir/file", "sym");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move.pass.cpp
index 1118ba23ab92f..4f8e8da93ba09 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move.pass.cpp
@@ -42,7 +42,7 @@ static void move_ctor() {
 static void move_ctor_copies_cache() {
   using namespace fs;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path sym = env.create_symlink("dir/file", "sym");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move_assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move_assign.pass.cpp
index a71f8ce314792..7516fbda9cdc0 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move_assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/move_assign.pass.cpp
@@ -46,7 +46,7 @@ static void test_move_assign_operator() {
 static void move_assign_copies_cache() {
   using namespace fs;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path sym = env.create_symlink("dir/file", "sym");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
index a1a37012369d4..96c7ed8cad34b 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.cons/path.pass.cpp
@@ -77,7 +77,7 @@ static void path_ec_ctor() {
 static void path_ctor_calls_refresh() {
   using namespace fs;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path sym = env.create_symlink("dir/file", "sym");
 
@@ -169,7 +169,7 @@ static void path_ctor_cannot_resolve() {
   scoped_test_env env;
   const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
-  const path file_out_of_dir = env.create_file("file1", 101);
+  env.create_file("file1", 101);
   const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
   const path sym_in_dir = env.create_symlink("dir/file1", "dir/sym2");
   permissions(dir, perms::none);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
index ba14af1240d4b..54baf451d65f1 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/assign.pass.cpp
@@ -70,7 +70,7 @@ static void test_path_assign_ec_method() {
 static void test_assign_calls_refresh() {
   using namespace fs;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path sym = env.create_symlink("dir/file", "sym");
 
@@ -120,7 +120,7 @@ static void test_assign_propagates_error() {
   const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
-  const path file_out_of_dir = env.create_file("file1");
+  env.create_file("file1");
   const path sym_in_dir = env.create_symlink("file1", "dir/sym1");
 
   permissions(dir, perms::none);
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp
index 20a545b719ed6..70ae4f9661c94 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/refresh.pass.cpp
@@ -227,6 +227,7 @@ static void refresh_cannot_resolve() {
     permissions(dir, perms::none);
     ((void)ent_file);
     ((void)ent_sym);
+    (void)ent_sym2;
 
     TEST_THROWS_TYPE(filesystem_error, ent_file.refresh());
     TEST_THROWS_TYPE(filesystem_error, ent_sym.refresh());
@@ -291,7 +292,7 @@ static void access_cache_after_refresh_fails() {
   scoped_test_env env;
   const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
-  const path file_out_of_dir = env.create_file("file1", 101);
+  env.create_file("file1", 101);
   const path sym = env.create_symlink("dir/file", "sym");
   const path sym_in_dir = env.create_symlink("dir/file", "dir/sym2");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
index 03e9de882ab0a..c19b3b5f72b4e 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.mods/replace_filename.pass.cpp
@@ -91,7 +91,7 @@ static void test_replace_filename_ec_method() {
 static void test_replace_filename_calls_refresh() {
   using namespace fs;
   scoped_test_env env;
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path file_two = env.create_file("dir/file_two", 101);
   const path sym = env.create_symlink("dir/file", "sym");
@@ -131,7 +131,7 @@ static void test_replace_filename_propagates_error() {
   const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
   const path file_two = env.create_file("dir/file_two", 99);
-  const path file_out_of_dir = env.create_file("file_three", 101);
+  env.create_file("file_three", 101);
   const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
   const path sym_out_of_dir_two = env.create_symlink("dir/file", "sym_two");
   const path sym_in_dir = env.create_symlink("file_two", "dir/sym_three");
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
index 10829f8a73db1..63b1afb3c0591 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_size.pass.cpp
@@ -51,7 +51,7 @@ static void basic() {
 
   scoped_test_env env;
   const path file = env.create_file("file", 42);
-  const path dir = env.create_dir("dir");
+  env.create_dir("dir");
   const path sym = env.create_symlink("file", "sym");
 
   {
@@ -123,7 +123,7 @@ static void error_reporting() {
 
   const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
-  const path file_out_of_dir = env.create_file("file2", 101);
+  env.create_file("file2", 101);
   const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
   const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
index 071ee7f6c891f..39c8e0ffad64f 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/file_type_obs.pass.cpp
@@ -31,6 +31,7 @@ namespace fs = std::filesystem;
 static void file_dne() {
   using namespace fs;
   directory_entry p("dne");
+  (void)p;
 }
 
 static void signatures() {
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
index 5d931891dd0eb..a65a23127977f 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/hard_link_count.pass.cpp
@@ -126,7 +126,7 @@ static void error_reporting() {
 
   const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
-  const path file_out_of_dir = env.create_file("file2", 101);
+  env.create_file("file2", 101);
   const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
   const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
index 82b94a3d6bf5f..6078cd5ceae33 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/last_write_time.pass.cpp
@@ -91,7 +91,7 @@ static void error_reporting() {
 
   const path dir = env.create_dir("dir");
   const path file = env.create_file("dir/file", 42);
-  const path file_out_of_dir = env.create_file("file2", 101);
+  env.create_file("file2", 101);
   const path sym_out_of_dir = env.create_symlink("dir/file", "sym");
   const path sym_in_dir = env.create_symlink("file2", "dir/sym2");
 
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/path.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/path.pass.cpp
index bdac3e78cafe4..80d134724fe98 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/path.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_entry/directory_entry.obs/path.pass.cpp
@@ -49,7 +49,6 @@ void test_path_conversion() {
   const path p("foo/bar/baz.exe");
   const path p2("abc");
   {
-    directory_entry nce;
     const directory_entry e("");
     // Check conversions exist
     static_assert(std::is_convertible<directory_entry&,        path const&>::value, "");
diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
index 8401dbd38cd71..e2a05d2fcb832 100644
--- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/directory_iterator.members/ctor.pass.cpp
@@ -231,6 +231,7 @@ static void test_open_on_dot_dir()
 
     std::error_code ec;
     directory_iterator it(testPath, ec);
+    (void)it;
     assert(!ec);
 }
 
diff --git a/libcxx/test/std/input.output/filesystems/class.filesystem_error/filesystem_error.members.pass.cpp b/libcxx/test/std/input.output/filesystems/class.filesystem_error/filesystem_error.members.pass.cpp
index 3eb81b15cede7..cde2474c966f7 100644
--- a/libcxx/test/std/input.output/filesystems/class.filesystem_error/filesystem_error.members.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.filesystem_error/filesystem_error.members.pass.cpp
@@ -118,7 +118,6 @@ void test_constructors() {
 
 void test_signatures() {
   using namespace fs;
-  const path p;
   std::error_code ec;
   const filesystem_error e("lala", ec);
   // const path& path1() const noexcept;
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
index f80a0bf27bec2..dacf74762b58f 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/copy_assign.pass.cpp
@@ -78,7 +78,6 @@ static void test_assignment_signature() {
 static void test_copy_to_end_iterator()
 {
     static_test_env static_env;
-    const recursive_directory_iterator endIt;
 
     const recursive_directory_iterator from = createInterestingIterator(static_env);
     const path entry = *from;
@@ -107,7 +106,6 @@ static void test_copy_from_end_iterator()
 static void test_copy_valid_iterator()
 {
     static_test_env static_env;
-    const recursive_directory_iterator endIt;
 
     const recursive_directory_iterator it = createInterestingIterator(static_env);
     const path entry = *it;
diff --git a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
index f7f1bd69fb736..a775031652e53 100644
--- a/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.rec.dir.itr/rec.dir.itr.members/recursion_pending.pass.cpp
@@ -101,7 +101,6 @@ static void value_after_move_construction_and_assignment_test()
 static void increment_resets_value()
 {
     static_test_env static_env;
-    const recursive_directory_iterator endIt;
     {
         recursive_directory_iterator it(static_env.Dir);
         it.disable_recursion_pending();
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
index 1c5c1f4a3c49a..af9ef1e3c201d 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.copy/copy.pass.cpp
@@ -158,7 +158,7 @@ static void from_is_regular_file()
 {
     scoped_test_env env;
     const path file = env.create_file("file", 42);
-    const path dir = env.create_dir("dir");
+    env.create_dir("dir");
     { // skip copy because of directory
         const path dest = env.make_env_path("dest1");
         std::error_code ec = GetTestEC();
@@ -270,7 +270,7 @@ static void test_copy_symlinks_to_symlink_dir()
     scoped_test_env env;
     const path file1 = env.create_file("file1", 42);
     const path file2 = env.create_file("file2", 101);
-    const path file2_sym = env.create_symlink(file2, "file2_sym");
+    env.create_symlink(file2, "file2_sym");
     const path dir = env.create_dir("dir");
     const path dir_sym = env.create_directory_symlink(dir, "dir_sym");
     {
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
index 1dc076a231389..bb32c92b8a985 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
@@ -70,7 +70,7 @@ static void create_directories_multi_level()
 
 static void create_directory_symlinks() {
   scoped_test_env env;
-  const path root = env.create_dir("dir");
+  env.create_dir("dir");
   const path sym_dest_dead = env.make_env_path("dead");
   const path dead_sym = env.create_directory_symlink(sym_dest_dead, "dir/sym_dir");
   const path target = env.make_env_path("dir/sym_dir/foo");
diff --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
index f3161f2e020d2..1004fb33247d3 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.is_empty/is_empty.pass.cpp
@@ -104,7 +104,7 @@ static void test_directory_access_denied()
         return;
 #else
     const path dir = env.create_dir("dir");
-    const path file1 = env.create_file("dir/file", 42);
+    env.create_file("dir/file", 42);
     permissions(dir, perms::none);
 #endif
 
diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
index 4b9745a1c3639..471350272daea 100644
--- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
+++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
@@ -24,6 +24,7 @@ TEST_CONSTEXPR_CXX20 bool
 test(C c)
 {
     std::back_insert_iterator<C> i(c);
+    (void)i;
     return true;
 }
 
diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
index c96b8527bef0a..aaf32cf8d66e5 100644
--- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
+++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
@@ -24,6 +24,7 @@ TEST_CONSTEXPR_CXX20 bool
 test(C c)
 {
     std::front_insert_iterator<C> i(c);
+    (void)i;
     return true;
 }
 
diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
index af2e85471ae4e..782d22af1fb51 100644
--- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
+++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
@@ -24,6 +24,7 @@ TEST_CONSTEXPR_CXX20 bool
 test(C c)
 {
     std::insert_iterator<C> i(c, c.begin());
+    (void)i;
     return true;
 }
 
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
index 0efde61aa3632..ab9b54b620ced 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
@@ -14,7 +14,6 @@
 
 #include <locale>
 #include <string>
-#include <vector>
 #include <cassert>
 
 #include <stdio.h>
@@ -28,7 +27,6 @@ int main(int, char**)
         typedef std::ctype<char> F;
         const F& f = std::use_facet<F>(l);
         const std::string in(" A\x07.a1");
-        std::vector<F::mask> m(in.size());
         assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
         assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
         assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
index 4d815f2e121ff..5f194bd157d6c 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
@@ -14,7 +14,6 @@
 
 #include <locale>
 #include <string>
-#include <vector>
 #include <cassert>
 
 #include <stdio.h>
@@ -28,7 +27,6 @@ int main(int, char**)
         typedef std::ctype<char> F;
         const F& f = std::use_facet<F>(l);
         const std::string in(" A\x07.a1");
-        std::vector<F::mask> m(in.size());
         assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
         assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
         assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
index ea03f042f2d45..78bd0a1ef210e 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
@@ -20,7 +20,6 @@
 
 #include <locale>
 #include <string>
-#include <vector>
 #include <cassert>
 
 #include <stdio.h>
@@ -36,7 +35,6 @@ int main(int, char**)
             typedef std::ctype<wchar_t> F;
             const F& f = std::use_facet<F>(l);
             const std::wstring in(L"\x00DA A\x07.a1");
-            std::vector<F::mask> m(in.size());
             assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
             assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
             assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
@@ -57,7 +55,6 @@ int main(int, char**)
             typedef std::ctype<wchar_t> F;
             const F& f = std::use_facet<F>(l);
             const std::wstring in(L"\x00DA A\x07.a1");
-            std::vector<F::mask> m(in.size());
             assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
             assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
             assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
index 2f7acb843e591..5f9788a0bfa5b 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
@@ -20,7 +20,6 @@
 
 #include <locale>
 #include <string>
-#include <vector>
 #include <cassert>
 
 #include <stdio.h>
@@ -36,7 +35,6 @@ int main(int, char**)
             typedef std::ctype<wchar_t> F;
             const F& f = std::use_facet<F>(l);
             const std::wstring in(L"\x00DA A\x07.a1");
-            std::vector<F::mask> m(in.size());
             assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
             assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 3);
             assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
@@ -57,7 +55,6 @@ int main(int, char**)
             typedef std::ctype<wchar_t> F;
             const F& f = std::use_facet<F>(l);
             const std::wstring in(L"\x00DA A\x07.a1");
-            std::vector<F::mask> m(in.size());
             assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
             assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
             assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
index 2078af74209eb..584ed22808399 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
@@ -16,7 +16,6 @@
 
 #include <locale>
 #include <string>
-#include <vector>
 #include <cassert>
 
 #include <stdio.h>
@@ -30,7 +29,6 @@ int main(int, char**)
         typedef std::ctype<wchar_t> F;
         const F& f = std::use_facet<F>(l);
         const std::wstring in(L" A\x07.a1");
-        std::vector<F::mask> m(in.size());
         assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
         assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
         assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
diff --git a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
index 77f8c9bb26f4e..b8b5a50b5ed20 100644
--- a/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
@@ -30,7 +30,6 @@ int main(int, char**)
         typedef std::ctype<wchar_t> F;
         const F& f = std::use_facet<F>(l);
         const std::wstring in(L" A\x07.a1");
-        std::vector<F::mask> m(in.size());
         assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
         assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
         assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
diff --git a/libcxx/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp b/libcxx/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
index d7f61e10f2d99..3ce997a7ff28a 100644
--- a/libcxx/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
@@ -311,15 +311,16 @@ int main(int, char**)
         std::string ex(str, base(iter));
         assert(ex == "09");
     }
+/*
     {
         cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), ios, '*', &t, 'Z');
         std::string ex(str, base(iter));
-//        assert(ex == "EDT");  depends on time zone
+        assert(ex == "EDT"); // depends on time zone
     }
     {
         cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), ios, '*', &t, 'z');
         std::string ex(str, base(iter));
-//        assert(ex == "-0400");  depends on time zone
+        assert(ex == "-0400"); // depends on time zone
     }
 #ifndef _WIN32
     // The Windows strftime() doesn't support the "%+" format. Depending on CRT
@@ -327,9 +328,10 @@ int main(int, char**)
     {
         cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), ios, '*', &t, '+');
         std::string ex(str, base(iter));
-//        assert(ex == "Sat May  2 13:03:06 EDT 2009");  depends on time zone
+        assert(ex == "Sat May  2 13:03:06 EDT 2009"); // depends on time zone
     }
 #endif
+*/
     {
         cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), ios, '*', &t, '%');
         std::string ex(str, base(iter));
diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
index 5585ec86d771a..1024130aa9035 100644
--- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
+++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
@@ -41,11 +41,11 @@ void TestHelper<CharT, 2>::test() {
     typedef std::wstring_convert<Codecvt> Myconv;
     Myconv myconv;
     assert(myconv.converted() == 0);
-    std::string bs = myconv.to_bytes(L"\u1005");
+    myconv.to_bytes(L"\u1005");
     assert(myconv.converted() == 1);
-    bs = myconv.to_bytes(L"\u1005e");
+    myconv.to_bytes(L"\u1005e");
     assert(myconv.converted() == 2);
-    std::wstring ws = myconv.from_bytes("\xE1\x80\x85");
+    myconv.from_bytes("\xE1\x80\x85");
     assert(myconv.converted() == 3);
   }
 }
@@ -58,11 +58,11 @@ void TestHelper<CharT, 4>::test() {
     typedef std::wstring_convert<Codecvt> Myconv;
     Myconv myconv;
     assert(myconv.converted() == 0);
-    std::string bs = myconv.to_bytes(L"\U00040003");
+    myconv.to_bytes(L"\U00040003");
     assert(myconv.converted() == 1);
-    bs = myconv.to_bytes(L"\U00040003e");
+    myconv.to_bytes(L"\U00040003e");
     assert(myconv.converted() == 2);
-    std::wstring ws = myconv.from_bytes("\xF1\x80\x80\x83");
+    myconv.from_bytes("\xF1\x80\x80\x83");
     assert(myconv.converted() == 4);
   }
 }
diff --git a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/general.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/general.pass.cpp
index 521c0b1610bce..9a32ceb22d482 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.lazy.split/general.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.lazy.split/general.pass.cpp
@@ -256,9 +256,6 @@ bool test_nontrivial_characters() {
     {"hijk", 5},
   };
 
-  Vec expected1 = {m1, m2};
-  Vec expected2 = {m3};
-
   std::ranges::lazy_split_view v(Vec{m1, m2, sep, m3}, sep);
 
   // Segment 1: {m1, m2}
diff --git a/libcxx/test/std/ranges/range.adaptors/range.split/general.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.split/general.pass.cpp
index 5389d931f840e..2888ee6837de9 100644
--- a/libcxx/test/std/ranges/range.adaptors/range.split/general.pass.cpp
+++ b/libcxx/test/std/ranges/range.adaptors/range.split/general.pass.cpp
@@ -204,9 +204,6 @@ bool test_nontrivial_characters() {
       {"hijk", 5},
   };
 
-  Vec expected1 = {m1, m2};
-  Vec expected2 = {m3};
-
   std::ranges::split_view v(Vec{m1, m2, sep, m3}, sep);
 
   // Segment 1: {m1, m2}
diff --git a/libcxx/test/std/ranges/range.utility/range.utility.conv/to_std_containers.pass.cpp b/libcxx/test/std/ranges/range.utility/range.utility.conv/to_std_containers.pass.cpp
index 4c19ea45b9a2c..e4f89bf76932d 100644
--- a/libcxx/test/std/ranges/range.utility/range.utility.conv/to_std_containers.pass.cpp
+++ b/libcxx/test/std/ranges/range.utility/range.utility.conv/to_std_containers.pass.cpp
@@ -61,7 +61,6 @@ void test_is_equal(std::vector<std::vector<typename From::value_type>> inputs) {
 template <class From, class To>
 void test_is_permutation(std::vector<std::vector<typename From::value_type>> inputs) {
   for (const auto& in : inputs) {
-    From from(in.begin(), in.end());
     std::same_as<To> decltype(auto) result = std::ranges::to<To>(in);
     assert(std::ranges::is_permutation(in, result));
   }
diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
index d57c0f700b8a5..7a5f53310fd22 100644
--- a/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
+++ b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
@@ -31,11 +31,6 @@ test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f,
 
 int main(int, char**)
 {
-    std::string s1("\\(a\\)");
-    std::string s2("\\(a[bc]\\)");
-    std::string s3("\\(a\\([bc]\\)\\)");
-    std::string s4("(a([bc]))");
-
     test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::basic, 1);
     test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::basic, 1);
     test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::basic, 2);
diff --git a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
index dcf697bed752f..6bb7326f54489 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -45,6 +45,7 @@ TEST_CONSTEXPR_CXX20 void test(SV sv, std::size_t pos, std::size_t n) {
   else if (!TEST_IS_CONSTANT_EVALUATED) {
     try {
       S s2(sv, static_cast<Size>(pos), static_cast<Size>(n));
+      (void)s2;
       assert(false);
     } catch (std::out_of_range&) {
       assert(pos > sv.size());
@@ -71,6 +72,7 @@ TEST_CONSTEXPR_CXX20 void test(SV sv, std::size_t pos, std::size_t n, const type
   else if (!TEST_IS_CONSTANT_EVALUATED) {
     try {
       S s2(sv, static_cast<Size>(pos), static_cast<Size>(n), a);
+      (void)s2;
       assert(false);
     } catch (std::out_of_range&) {
       assert(pos > sv.size());
diff --git a/libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
index d5c1f4d9348b8..637ac31e6d235 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
@@ -45,6 +45,7 @@ TEST_CONSTEXPR_CXX20 bool test() {
   {
     std::basic_string<char, std::char_traits<char>, test_allocator<char>> str2((test_allocator<char>(&alloc_stats)));
     str2 = "long long string so no SSO";
+    (void)str2;
     assert(alloc_stats.alloc_count > 0);
     LIBCPP_ASSERT(alloc_stats.alloc_count == 1);
   }
diff --git a/libcxx/test/std/strings/basic.string/string.cons/from_range.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/from_range.pass.cpp
index c110a59d606ff..aa5850f27b789 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/from_range.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/from_range.pass.cpp
@@ -101,6 +101,7 @@ void test_string_exception_safety_throwing_allocator() {
     // Note: the input string must be long enough to prevent SSO, otherwise the allocator won't be used.
     std::basic_string<char, std::char_traits<char>, ThrowingAllocator<char>> c(
         std::from_range, std::vector<char>(64, 'A'), alloc);
+    (void)c;
     assert(false); // The constructor call should throw.
 
   } catch (int) {
diff --git a/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp
index 93a8e59349634..4a9a3d8ca3223 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/move_alloc.pass.cpp
@@ -61,6 +61,7 @@ TEST_CONSTEXPR_CXX20 bool test() {
 #endif
     S s1("Twas brillig, and the slivy toves did gyre and gymbal in the wabe", A(&alloc_stats));
     S s2(std::move(s1), A(1, &alloc_stats));
+    (void)s2;
   }
   assert(alloc_stats.alloc_count == alloc_count);
   {
diff --git a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp
index cafd9674f4898..b895619a71e83 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp
@@ -47,6 +47,7 @@ TEST_CONSTEXPR_CXX20 void test(S str, unsigned pos) {
   else if (!TEST_IS_CONSTANT_EVALUATED) {
     try {
       S s2(str, pos);
+      (void)s2;
       assert(false);
     } catch (std::out_of_range&) {
       assert(pos > str.size());
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
index 6a66a0067b390..40990df375187 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -36,7 +36,7 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::size_type pos, typename S
 #ifndef TEST_HAS_NO_EXCEPTIONS
   else if (!TEST_IS_CONSTANT_EVALUATED) {
     try {
-      S str = s.substr(pos, n);
+      (void)s.substr(pos, n);
       assert(false);
     } catch (std::out_of_range&) {
       assert(pos > s.size());
diff --git a/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
index 40daa49393bd4..b12b9ace5f710 100644
--- a/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/thread_create_failure.pass.cpp
@@ -52,12 +52,14 @@ int main(int, char**) {
 
   try {
     std::future<int> fut = std::async(std::launch::async, [] { return 1; });
+    (void)fut;
     assert(false);
   } catch (const std::system_error&) {
   }
 
   try {
     std::future<void> fut = std::async(std::launch::async, [] { return; });
+    (void)fut;
     assert(false);
   } catch (const std::system_error&) {
   }
diff --git a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
index 7384a195bb360..5e646a01fad5a 100644
--- a/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.async/wait_on_destruct.pass.cpp
@@ -28,7 +28,7 @@ std::mutex mux;
 int main(int, char**) {
   std::condition_variable cond;
   std::unique_lock lock(mux);
-  auto v = std::async(std::launch::async, [&cond, value = 1]() mutable {
+  (void)std::async(std::launch::async, [&cond, value = 1]() mutable {
     std::unique_lock thread_lock(mux);
     cond.notify_all();
     thread_lock.unlock();
diff --git a/libcxx/test/std/thread/futures/futures.promise/get_future.pass.cpp b/libcxx/test/std/thread/futures/futures.promise/get_future.pass.cpp
index e90e395a96b84..5143ce2a3234a 100644
--- a/libcxx/test/std/thread/futures/futures.promise/get_future.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.promise/get_future.pass.cpp
@@ -35,6 +35,7 @@ int main(int, char**)
         try
         {
             f = p.get_future();
+            (void)f;
             assert(false);
         }
         catch (const std::future_error& e)
@@ -45,9 +46,11 @@ int main(int, char**)
     {
         std::promise<double> p;
         std::promise<double> p0 = std::move(p);
+        (void)p0;
         try
         {
             std::future<double> f = p.get_future();
+            (void)f;
             assert(false);
         }
         catch (const std::future_error& e)
diff --git a/libcxx/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp b/libcxx/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp
index f5a6ab937d611..991507e27c3d5 100644
--- a/libcxx/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp
@@ -52,6 +52,7 @@ int main(int, char**)
         T i;
         std::promise<T> p;
         std::future<T> f = p.get_future();
+        (void)f;
         try
         {
             p.set_value(std::move(i));
diff --git a/libcxx/test/std/thread/futures/futures.promise/set_value_const.pass.cpp b/libcxx/test/std/thread/futures/futures.promise/set_value_const.pass.cpp
index c4c89550272a5..a2d54f24765a0 100644
--- a/libcxx/test/std/thread/futures/futures.promise/set_value_const.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.promise/set_value_const.pass.cpp
@@ -56,6 +56,7 @@ int main(int, char**)
         T i;
         std::promise<T> p;
         std::future<T> f = p.get_future();
+        (void)f;
 #ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
diff --git a/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp b/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
index 7c5931d18bc30..f23e858132e4f 100644
--- a/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
+++ b/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
@@ -45,6 +45,7 @@ int main(int, char**)
         try
         {
             f = p.get_future();
+            (void)f;
             assert(false);
         }
         catch (const std::future_error& e)
diff --git a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
index 0cf70ad3c517b..6d33d32e255f1 100644
--- a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
+++ b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
@@ -22,6 +22,7 @@
 int main(int, char**)
 {
     std::condition_variable_any cv;
+    (void)cv;
 
   return 0;
 }
diff --git a/libcxx/test/std/utilities/any/any.class/any.cons/copy.pass.cpp b/libcxx/test/std/utilities/any/any.class/any.cons/copy.pass.cpp
index c804887ff68f0..d97f179b8cd01 100644
--- a/libcxx/test/std/utilities/any/any.class/any.cons/copy.pass.cpp
+++ b/libcxx/test/std/utilities/any/any.class/any.cons/copy.pass.cpp
@@ -28,6 +28,7 @@ void test_copy_throws() {
         assert(Type::count == 1);
         try {
             const std::any a2(a);
+            (void)a2;
             assert(false);
         } catch (my_any_exception const &) {
             // do nothing
diff --git a/libcxx/test/std/utilities/any/any.class/any.cons/value.pass.cpp b/libcxx/test/std/utilities/any/any.class/any.cons/value.pass.cpp
index b78f72210f7da..2d47d278103c6 100644
--- a/libcxx/test/std/utilities/any/any.class/any.cons/value.pass.cpp
+++ b/libcxx/test/std/utilities/any/any.class/any.cons/value.pass.cpp
@@ -59,6 +59,7 @@ void test_move_value_throws()
         assert(throws_on_move::count == 1);
         try {
             std::any a = std::move(v);
+            (void)a;
             assert(false);
         } catch (const my_any_exception&) {
             // do nothing
diff --git a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.default.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.default.pass.cpp
index 9f9ff7ee7717d..2d695e94b9cb7 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.default.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.default.pass.cpp
@@ -67,6 +67,7 @@ void testException() {
 
   try {
     std::expected<Throwing, int> u;
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace.pass.cpp
index 31de6e4e0243c..84f7c0359db28 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace.pass.cpp
@@ -122,6 +122,7 @@ void testException() {
 
   try {
     std::expected<Throwing, int> u(std::in_place, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace_init_list.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace_init_list.pass.cpp
index ed2afbbeb910b..64be8f0e5454e 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace_init_list.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.inplace_init_list.pass.cpp
@@ -109,6 +109,7 @@ void testException() {
 
   try {
     std::expected<Throwing, int> u(std::in_place, {1, 2}, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.u.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.u.pass.cpp
index fe664dfc97cfe..3456c674aca90 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.u.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.u.pass.cpp
@@ -202,6 +202,7 @@ void testException() {
 
   try {
     std::expected<Throwing, int> u(5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect.pass.cpp
index f71d17c8df400..fb171e0a22cd2 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect.pass.cpp
@@ -122,6 +122,7 @@ void testException() {
 
   try {
     std::expected<int, Throwing> u(std::unexpect, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect_init_list.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect_init_list.pass.cpp
index 6da98e11c4a13..b711fef0bb474 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect_init_list.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.unexpect_init_list.pass.cpp
@@ -109,6 +109,7 @@ void testException() {
 
   try {
     std::expected<int, Throwing> u(std::unexpect, {1, 2}, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.expected/dtor.pass.cpp b/libcxx/test/std/utilities/expected/expected.expected/dtor.pass.cpp
index a4250e606d6b3..ff5dac0c60344 100644
--- a/libcxx/test/std/utilities/expected/expected.expected/dtor.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.expected/dtor.pass.cpp
@@ -60,6 +60,7 @@ constexpr bool test() {
 
 int main(int, char**) {
   std::expected<std::unique_ptr<int>, int> a = std::make_unique<int>(42);
+  (void)a;
 
   test();
   static_assert(test());
diff --git a/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.error.pass.cpp b/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.error.pass.cpp
index bdeb74e3b45fc..ba72b75b13288 100644
--- a/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.error.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.error.pass.cpp
@@ -109,6 +109,7 @@ void testException() {
   Throwing t;
   try {
     std::unexpected<Throwing> u(t);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace.pass.cpp b/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace.pass.cpp
index 3e842444d9cb7..937756db1fb06 100644
--- a/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace.pass.cpp
@@ -90,6 +90,7 @@ void testException() {
 
   try {
     std::unexpected<Throwing> u(std::in_place, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace_init_list.pass.cpp b/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace_init_list.pass.cpp
index b8927f5947ca7..650e2f6e97144 100644
--- a/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace_init_list.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.inplace_init_list.pass.cpp
@@ -90,6 +90,7 @@ void testException() {
 
   try {
     std::unexpected<Throwing> u(std::in_place, {1, 2}, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect.pass.cpp b/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect.pass.cpp
index 4e7657cb878f7..6ceb53b7d03dc 100644
--- a/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect.pass.cpp
@@ -122,6 +122,7 @@ void testException() {
 
   try {
     std::expected<void, Throwing> u(std::unexpect, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect_init_list.pass.cpp b/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect_init_list.pass.cpp
index 7ece9dba04032..66fc773fb7938 100644
--- a/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect_init_list.pass.cpp
+++ b/libcxx/test/std/utilities/expected/expected.void/ctor/ctor.unexpect_init_list.pass.cpp
@@ -108,6 +108,7 @@ void testException() {
 
   try {
     std::expected<void, Throwing> u(std::unexpect, {1, 2}, 5);
+    (void)u;
     assert(false);
   } catch (Except) {
   }
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
index a5a8c5936cc03..d71a104f8876b 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
@@ -20,6 +20,7 @@
 int main(int, char**)
 {
     std::bad_function_call ex;
+    (void)ex;
 
   return 0;
 }
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
index 531324fa7cce1..e096846c46c2d 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
@@ -21,13 +21,6 @@
 
 #include "test_macros.h"
 
-struct X{
-    typedef std::function<void(X&)> callback_type;
-    virtual ~X() {}
-private:
-    callback_type _cb;
-};
-
 struct IncompleteReturnType {
   std::function<IncompleteReturnType ()> fn;
 };
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/noncopyable_return_type.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/noncopyable_return_type.pass.cpp
index afc5915859377..5b35848c86210 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/noncopyable_return_type.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/noncopyable_return_type.pass.cpp
@@ -78,24 +78,36 @@ void void_test()
 {
     std::function<void()> f1a = []() { return NonCopyable(); };
     std::function<void()> f2a = +[]() { return NonCopyable(); };
+    (void)f2a;
     std::function<void()> f3a = LargeLambda();
+    (void)f3a;
     std::function<void()> f4a = std::ref(f1a);
+    (void)f4a;
     std::function<void(int)> f1b = [](int) { return NonCopyable(); };
     std::function<void(int)> f2b = +[](int) { return NonCopyable(); };
+    (void)f2b;
     std::function<void(int)> f3b = LargeLambda();
+    (void)f3b;
     std::function<void(int)> f4b = std::ref(f1b);
+    (void)f4b;
 }
 
 void const_void_test()
 {
     std::function<const void()> f1a = []() { return NonCopyable(); };
     std::function<const void()> f2a = +[]() { return NonCopyable(); };
+    (void)f2a;
     std::function<const void()> f3a = LargeLambda();
+    (void)f3a;
     std::function<const void()> f4a = std::ref(f1a);
+    (void)f4a;
     std::function<const void(int)> f1b = [](int) { return NonCopyable(); };
     std::function<const void(int)> f2b = +[](int) { return NonCopyable(); };
+    (void)f2b;
     std::function<const void(int)> f3b = LargeLambda();
+    (void)f3b;
     std::function<const void(int)> f4b = std::ref(f1b);
+    (void)f4b;
 }
 
 void member_pointer_test()
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/robust_against_adl.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/robust_against_adl.pass.cpp
index 3c0851e4eebe0..862ba855eee5d 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/robust_against_adl.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/robust_against_adl.pass.cpp
@@ -49,5 +49,6 @@ int main(int, char**) {
     std::function<Ptr(Ptr)> g(one_arg); g(x);
     std::function<void(Ptr)> h(one_arg_void); h(x);
     std::function<void()> i(Callable<Holder<Incomplete>>{});
+    (void)i;
     return 0;
 }
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap.pass.cpp
index 70e79d399861a..70336f2827c57 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap.pass.cpp
@@ -38,8 +38,6 @@ constexpr void test() {
   std::reference_wrapper<T> rw1{i};
   std::reference_wrapper<T> rw2 = rw1;
   std::reference_wrapper<T> rw3{j};
-  std::reference_wrapper<const T> crw1{i};
-  std::reference_wrapper<const T> crw3{j};
 
   AssertEqualityReturnBool<decltype(rw1), decltype(rw2)>();
   assert(testEquality(rw1, rw2, true));
diff --git a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap_const.pass.cpp b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap_const.pass.cpp
index c68ad5c4aa527..97ab6b914c017 100644
--- a/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap_const.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/refwrap/refwrap.comparisons/equal.refwrap.refwrap_const.pass.cpp
@@ -40,7 +40,6 @@ constexpr void test() {
 
   std::reference_wrapper<T> rw1{i};
 
-  std::reference_wrapper<T> rw3{j};
   std::reference_wrapper<const T> crw1{i};
   std::reference_wrapper<const T> crw3{j};
 
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp
index 8d3cbc106abc3..5dcb71344c1aa 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp
@@ -29,6 +29,7 @@ int main(int, char**)
 {
     X x;
     std::function<void()> f(x);
+    (void)f;
 
   return 0;
 }
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_deque_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_deque_synop2.pass.cpp
index c7a30520f09be..7e991f530d363 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_deque_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_deque_synop2.pass.cpp
@@ -24,6 +24,7 @@ int main(int, char**) {
   {
     // Check that std::pmr::deque is usable without <memory_resource>.
     std::pmr::deque<int> d;
+    (void)d;
   }
 
   return 0;
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_list_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_list_synop2.pass.cpp
index 39936aa9490a7..da02bb67b8b75 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_list_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_list_synop2.pass.cpp
@@ -24,6 +24,7 @@ int main(int, char**) {
   {
     // Check that std::pmr::list is usable without <memory_resource>.
     std::pmr::list<int> l;
+    (void)l;
   }
 
   return 0;
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_map_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_map_synop2.pass.cpp
index d127f0f71bb9d..18e838c059b36 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_map_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_map_synop2.pass.cpp
@@ -24,7 +24,9 @@ int main(int, char**) {
   {
     // Check that std::pmr::map is usable without <memory_resource>.
     std::pmr::map<int, int> m;
+    (void)m;
     std::pmr::multimap<int, int> mm;
+    (void)mm;
   }
 
   return 0;
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_set_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_set_synop2.pass.cpp
index ad8b637606633..51c479a91ce16 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_set_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_set_synop2.pass.cpp
@@ -24,7 +24,9 @@ int main(int, char**) {
   {
     // Check that std::pmr::set is usable without <memory_resource>.
     std::pmr::set<int> s;
+    (void)s;
     std::pmr::multiset<int> ms;
+    (void)ms;
   }
 
   return 0;
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_string_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_string_synop2.pass.cpp
index c86130df5032f..13a7f6e4bef17 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_string_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_string_synop2.pass.cpp
@@ -29,11 +29,15 @@ int main(int, char**) {
   {
     // Check that std::pmr::string is usable without <memory_resource>.
     std::pmr::string s;
+    (void)s;
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
     std::pmr::wstring ws;
+    (void)ws;
 #endif
     std::pmr::u16string u16s;
+    (void)u16s;
     std::pmr::u32string u32s;
+    (void)u32s;
   }
 
   return 0;
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_map_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_map_synop2.pass.cpp
index ccb3e1761967d..151d30e59f59b 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_map_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_map_synop2.pass.cpp
@@ -24,7 +24,9 @@ int main(int, char**) {
   {
     // Check that std::pmr::unordered_map is usable without <memory_resource>.
     std::pmr::unordered_map<int, int> m;
+    (void)m;
     std::pmr::unordered_multimap<int, int> mm;
+    (void)mm;
   }
 
   return 0;
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_set_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_set_synop2.pass.cpp
index 1d753087dca06..d990c3fac46aa 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_set_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_unordered_set_synop2.pass.cpp
@@ -24,7 +24,9 @@ int main(int, char**) {
   {
     // Check that std::pmr::unordered_set is usable without <memory_resource>.
     std::pmr::unordered_set<int> s;
+    (void)s;
     std::pmr::unordered_multiset<int> ms;
+    (void)ms;
   }
 
   return 0;
diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_vector_synop2.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_vector_synop2.pass.cpp
index 2f5a5574eb694..690a913768128 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_vector_synop2.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.aliases/header_vector_synop2.pass.cpp
@@ -24,6 +24,7 @@ int main(int, char**) {
   {
     // Check that std::pmr::vector is usable without <memory_resource>.
     std::pmr::vector<int> l;
+    (void)l;
   }
 
   return 0;



More information about the libcxx-commits mailing list