diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp --- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include diff --git a/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp --- a/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp +++ b/libcxx/test/std/concepts/concepts.lang/concept.swappable/swappable.pass.cpp @@ -150,7 +150,8 @@ constexpr bool check_throwable_adl_swappable_arrays() { throwable_adl_swappable x[] = {{0}, {1}, {2}, {3}}; throwable_adl_swappable y[] = {{4}, {5}, {6}, {7}}; - return check_swap_22(x, y) && !noexcept(std::ranges::swap(x, y)); + constexpr auto not_noexcept = !noexcept(std::ranges::swap(x, y)); + return check_swap_22(x, y) && not_noexcept; } static_assert(check_throwable_adl_swappable_arrays()); diff --git a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp @@ -13,6 +13,7 @@ #include #include +#include #include "test_macros.h" #include "min_allocator.h" diff --git a/libcxx/test/std/containers/sequences/vector/access.pass.cpp b/libcxx/test/std/containers/sequences/vector/access.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/access.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/access.pass.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "min_allocator.h" #include "test_macros.h" @@ -39,7 +40,7 @@ template void test_get_basic(Vector& c, int start_value) { - const int n = c.size(); + const int n = static_cast(c.size()); for (int i = 0; i < n; ++i) assert(c[i] == start_value + i); for (int i = 0; i < n; ++i) @@ -47,7 +48,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - c.at(n); + TEST_IGNORE_NODISCARD c.at(n); assert(false); } catch (const std::out_of_range&) {} #endif diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp @@ -12,6 +12,7 @@ #include #include +#include #include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" diff --git a/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp --- a/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp +++ b/libcxx/test/std/containers/views/span.cons/initializer_list.pass.cpp @@ -22,12 +22,12 @@ }; constexpr int count(std::span sp) { - return sp.size(); + return static_cast(sp.size()); } template constexpr int countn(std::span sp) { - return sp.size(); + return static_cast(sp.size()); } constexpr bool test() { diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp @@ -20,6 +20,10 @@ #include "test_macros.h" +#ifdef _MSC_VER +#pragma warning (disable: 4244) // conversion from 'double' to 'NoIteratorAlias::value_type', possible loss of data +#endif + struct NoIteratorAlias { double data_[3] = {}; using value_type = int; diff --git a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp --- a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp +++ b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.hash/hash.pass.cpp @@ -30,10 +30,10 @@ template void do_test(int *LHSVal, int *RHSVal) { - const size_t ExpectLHS = std::hash{}((LHSVal)); - const size_t ExpectRHS = std::hash{}((RHSVal)); - const C LHS = C::from_address((LHSVal)); - const C RHS = C::from_address((RHSVal)); + [[maybe_unused]] const size_t ExpectLHS = std::hash{}(LHSVal); + [[maybe_unused]] const size_t ExpectRHS = std::hash{}(RHSVal); + const C LHS = C::from_address(LHSVal); + const C RHS = C::from_address(RHSVal); const std::hash h; LIBCPP_ASSERT(h(LHS) == ExpectLHS); diff --git a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp --- a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp +++ b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.pass.cpp @@ -36,9 +36,9 @@ assert(c.address() == &dummy); } { - C::from_address((int*)nullptr); - C::from_address((void*)nullptr); - C::from_address((char*)nullptr); + TEST_IGNORE_NODISCARD C::from_address((int*)nullptr); + TEST_IGNORE_NODISCARD C::from_address((void*)nullptr); + TEST_IGNORE_NODISCARD C::from_address((char*)nullptr); } { char dummy = 42; diff --git a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp --- a/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp +++ b/libcxx/test/std/language.support/support.coroutines/coroutine.handle/coroutine.handle.noop/noop_coroutine.pass.cpp @@ -69,7 +69,7 @@ assert(base); assert(base.done() == false); - h.promise(); + TEST_IGNORE_NODISCARD h.promise(); assert(h.address() == base.address()); assert(h == base); assert(h.address() != nullptr); diff --git a/libcxx/test/std/numerics/bit/byteswap.pass.cpp b/libcxx/test/std/numerics/bit/byteswap.pass.cpp --- a/libcxx/test/std/numerics/bit/byteswap.pass.cpp +++ b/libcxx/test/std/numerics/bit/byteswap.pass.cpp @@ -43,6 +43,9 @@ return {static_cast(0xABCDFE9477936406), static_cast(0x0664937794FECDAB)}; } assert(false); +#ifdef _MSC_VER + __assume(false); // *sigh* `assert` can return on MSVC - swear this one won't +#endif } template @@ -57,8 +60,8 @@ test_num(0x01234567, 0x67452301); test_num(0x0123456789ABCDEF, 0xEFCDAB8967452301); - test_num(0xAB, 0xAB); - test_num(0xCDEF, 0xEFCD); + test_num(static_cast(0xAB), static_cast(0xAB)); + test_num(static_cast(0xCDEF), static_cast(0xEFCD)); test_num(0x01234567, 0x67452301); test_num(0x0123456789ABCDEF, 0xEFCDAB8967452301); @@ -71,7 +74,7 @@ test_num(true, true); test_num(false, false); - test_num(0xCD, 0xCD); + test_num(static_cast(0xCD), static_cast(0xCD)); test_num(0xEF, 0xEF); test_num(0x45, 0x45); test_num(0xAB, 0xAB); diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/ranges/range.factories/range.iota.view/range_concept_conformance.compile.pass.cpp @@ -21,10 +21,10 @@ auto operator<=>(const Decrementable&) const = default; - constexpr Decrementable& operator++(); - constexpr Decrementable operator++(int); - constexpr Decrementable& operator--(); - constexpr Decrementable operator--(int); + Decrementable& operator++(); + Decrementable operator++(int); + Decrementable& operator--(); + Decrementable operator--(int); }; struct Incrementable { @@ -32,8 +32,8 @@ auto operator<=>(const Incrementable&) const = default; - constexpr Incrementable& operator++(); - constexpr Incrementable operator++(int); + Incrementable& operator++(); + Incrementable operator++(int); }; static_assert(std::ranges::random_access_range>); diff --git a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp --- a/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp +++ b/libcxx/test/std/ranges/range.factories/range.iota.view/size.pass.cpp @@ -65,7 +65,7 @@ } { const std::ranges::iota_view io(0, std::numeric_limits::max()); - assert(io.size() == std::numeric_limits::max()); + assert(io.size() == static_cast(std::numeric_limits::max())); } // Neither are integer like. diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp @@ -14,6 +14,7 @@ // void resize_and_overwrite(size_type n, Operation op) #include +#include #include #include "make_string.h" diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp --- a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/class.pass.cpp @@ -31,7 +31,7 @@ void test() { using Context = std::basic_format_context; { - auto store = std::make_format_args(); + [[maybe_unused]] auto store = std::make_format_args(); LIBCPP_STATIC_ASSERT( std::is_same_v>); LIBCPP_STATIC_ASSERT( @@ -40,7 +40,7 @@ LIBCPP_ASSERT(store.__args.size() == 0); } { - auto store = std::make_format_args(1); + [[maybe_unused]] auto store = std::make_format_args(1); LIBCPP_STATIC_ASSERT( std::is_same_v>); LIBCPP_STATIC_ASSERT( @@ -49,7 +49,7 @@ LIBCPP_ASSERT(store.__args.size() == 1); } { - auto store = std::make_format_args(1, 'c'); + [[maybe_unused]] auto store = std::make_format_args(1, 'c'); LIBCPP_STATIC_ASSERT( std::is_same_v>); @@ -59,7 +59,7 @@ LIBCPP_ASSERT(store.__args.size() == 2); } { - auto store = std::make_format_args(1, 'c', nullptr); + [[maybe_unused]] auto store = std::make_format_args(1, 'c', nullptr); LIBCPP_STATIC_ASSERT( std::is_same_v>); diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp --- a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.pass.cpp @@ -25,10 +25,10 @@ #include "test_macros.h" int main(int, char**) { - using Context = std::basic_format_context< + using Context [[maybe_unused]] = std::basic_format_context< std::back_insert_iterator>, char>; - auto value = std::make_format_args(42, nullptr, false, 1.0); + [[maybe_unused]] auto value = std::make_format_args(42, nullptr, false, 1.0); LIBCPP_ASSERT(value.__args.size() == 4); LIBCPP_ASSERT(test_basic_format_arg(value.__args[0], 42)); diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp --- a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_wformat_args.pass.cpp @@ -25,10 +25,10 @@ #include "test_macros.h" int main(int, char**) { - using Context = std::basic_format_context< + using Context [[maybe_unused]] = std::basic_format_context< std::back_insert_iterator>, wchar_t>; - auto value = std::make_wformat_args(42, nullptr, false, 1.0); + [[maybe_unused]] auto value = std::make_wformat_args(42, nullptr, false, 1.0); LIBCPP_ASSERT(value.__args.size() == 4); LIBCPP_ASSERT(test_basic_format_arg(value.__args[0], 42)); diff --git a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp --- a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp +++ b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/check_arg_id.pass.cpp @@ -35,13 +35,14 @@ void test_exception() { [] { std::format_parse_context context("", 1); - context.next_arg_id(); + TEST_IGNORE_NODISCARD context.next_arg_id(); try { context.check_arg_id(0); assert(false); } catch (const std::format_error& e) { LIBCPP_ASSERT(strcmp(e.what(), "Using manual argument numbering in automatic " "argument numbering mode") == 0); + (void) e; return; } assert(false); diff --git a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp --- a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp +++ b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp @@ -37,11 +37,12 @@ context.check_arg_id(0); try { - context.next_arg_id(); + TEST_IGNORE_NODISCARD context.next_arg_id(); assert(false); } catch (const std::format_error& e) { LIBCPP_ASSERT(strcmp(e.what(), "Using automatic argument numbering in manual " "argument numbering mode") == 0); + (void) e; return; } assert(false); diff --git a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp @@ -68,10 +68,10 @@ } assert(false); #else - (void)what; (void)fmt; (void)sizeof...(args); #endif + (void)what; }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/format_tests.h b/libcxx/test/std/utilities/format/format.functions/format_tests.h --- a/libcxx/test/std/utilities/format/format.functions/format_tests.h +++ b/libcxx/test/std/utilities/format/format.functions/format_tests.h @@ -164,7 +164,7 @@ STR("hello {:{}}"), world, -1); check_exception( "A format-spec arg-id replacement exceeds the maximum supported value", - STR("hello {:{}}"), world, -1u); + STR("hello {:{}}"), world, ~0u); check_exception("Argument index out of bounds", STR("hello {:{}}"), world); check_exception( "A format-spec arg-id replacement argument isn't an integral type", @@ -200,7 +200,7 @@ STR("hello {:.{}}"), world, -1); check_exception( "A format-spec arg-id replacement exceeds the maximum supported value", - STR("hello {:.{}}"), world, -1u); + STR("hello {:.{}}"), world, ~0u); check_exception("Argument index out of bounds", STR("hello {:.{}}"), world); check_exception( "A format-spec arg-id replacement argument isn't an integral type", diff --git a/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/vformat.locale.pass.cpp @@ -36,19 +36,21 @@ std::string_view what, std::basic_string fmt, const Args&... args) { #ifndef TEST_HAS_NO_EXCEPTIONS try { - std::vformat(std::locale(), fmt, - std::make_format_args>(args...)); + TEST_IGNORE_NODISCARD + std::vformat(std::locale(), fmt, + std::make_format_args>(args...)); assert(false); } catch (std::format_error& e) { LIBCPP_ASSERT(e.what() == what); + (void)e; return; } assert(false); #else - (void)what; (void)fmt; (void)sizeof...(args); #endif + (void)what; }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp @@ -35,18 +35,19 @@ std::string_view what, std::basic_string fmt, const Args&... args) { #ifndef TEST_HAS_NO_EXCEPTIONS try { - std::vformat(fmt, std::make_format_args>(args...)); + TEST_IGNORE_NODISCARD std::vformat(fmt, std::make_format_args>(args...)); assert(false); } catch (std::format_error& e) { LIBCPP_ASSERT(e.what() == what); + (void)e; return; } assert(false); #else - (void)what; (void)fmt; (void)sizeof...(args); #endif + (void)what; }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp @@ -76,14 +76,15 @@ assert(false); } catch (std::format_error& e) { LIBCPP_ASSERT(e.what() == what); + (void)e; return; } assert(false); #else - (void)what; (void)fmt; (void)sizeof...(args); #endif + (void)what; }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp @@ -76,14 +76,15 @@ assert(false); } catch (std::format_error& e) { LIBCPP_ASSERT(e.what() == what); + (void)e; return; } assert(false); #else - (void)what; (void)fmt; (void)sizeof...(args); #endif + (void)what; }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp @@ -73,7 +73,7 @@ { int i_; public: - constexpr explicit Z(int i) : i_(i) { TEST_THROW(6);} + explicit Z(int i) : i_(i) {TEST_THROW(6);} friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} }; diff --git a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp --- a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp @@ -380,7 +380,7 @@ // Check that visit unambiguously picks the variant, even if the other base has __impl member. struct ImplVariantBase { struct Callable { - bool operator()(); + bool operator()() { std::abort(); } }; Callable __impl; diff --git a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp --- a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp @@ -451,7 +451,7 @@ // Check that visit unambiguously picks the variant, even if the other base has __impl member. struct ImplVariantBase { struct Callable { - bool operator()(); + bool operator()() const { std::abort(); } }; Callable __impl; diff --git a/libcxx/test/support/charconv_test_helpers.h b/libcxx/test/support/charconv_test_helpers.h --- a/libcxx/test/support/charconv_test_helpers.h +++ b/libcxx/test/support/charconv_test_helpers.h @@ -108,7 +108,7 @@ // Poison the buffer for testing whether a successful std::to_chars // doesn't modify data beyond r.ptr. - std::iota(buf, buf + sizeof(buf), 1); + std::iota(buf, buf + sizeof(buf), char{1}); r = to_chars(buf, buf + sizeof(buf), v, args...); assert(r.ec == std::errc{}); for (size_t i = r.ptr - buf; i < sizeof(buf); ++i) diff --git a/libcxx/test/support/test_constexpr_container.h b/libcxx/test/support/test_constexpr_container.h --- a/libcxx/test/support/test_constexpr_container.h +++ b/libcxx/test/support/test_constexpr_container.h @@ -38,7 +38,7 @@ constexpr const T& back() const { assert(size_ >= 1); return data_[size_-1]; } constexpr iterator insert(const_iterator pos, T t) { - int i = (pos - data_); + int i = static_cast(pos - data_); if (i != size_) { std::move_backward(data_ + i, data_ + size_, data_ + size_ + 1); }