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 @@ -70,55 +70,59 @@ constexpr bool check_lvalue_adl_swappable() { auto x = lvalue_adl_swappable(0); auto y = lvalue_adl_swappable(1); - constexpr auto is_noexcept = noexcept(std::ranges::swap(x, y)); - return check_swap_21(x, y) && is_noexcept; + ASSERT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_21(x, y)); + return true; } static_assert(check_lvalue_adl_swappable()); constexpr bool check_rvalue_adl_swappable() { - constexpr auto is_noexcept = noexcept( - std::ranges::swap(rvalue_adl_swappable(0), rvalue_adl_swappable(1))); - return check_swap_21(rvalue_adl_swappable(0), rvalue_adl_swappable(1)) && - is_noexcept; + ASSERT_NOEXCEPT(std::ranges::swap(rvalue_adl_swappable(0), rvalue_adl_swappable(1))); + assert(check_swap_21(rvalue_adl_swappable(0), rvalue_adl_swappable(1))); + return true; } static_assert(check_rvalue_adl_swappable()); constexpr bool check_lvalue_rvalue_adl_swappable() { auto x = lvalue_rvalue_adl_swappable(0); - constexpr auto is_noexcept = - noexcept(std::ranges::swap(x, lvalue_rvalue_adl_swappable(1))); - return check_swap_21(x, lvalue_rvalue_adl_swappable(1)) && is_noexcept; + ASSERT_NOEXCEPT(std::ranges::swap(x, lvalue_rvalue_adl_swappable(1))); + assert(check_swap_21(x, lvalue_rvalue_adl_swappable(1))); + return true; } static_assert(check_lvalue_rvalue_adl_swappable()); constexpr bool check_rvalue_lvalue_adl_swappable() { auto x = rvalue_lvalue_adl_swappable(0); - constexpr auto is_noexcept = - noexcept(std::ranges::swap(rvalue_lvalue_adl_swappable(1), x)); - return check_swap_21(rvalue_lvalue_adl_swappable(1), x) && is_noexcept; + ASSERT_NOEXCEPT(std::ranges::swap(rvalue_lvalue_adl_swappable(1), x)); + assert(check_swap_21(rvalue_lvalue_adl_swappable(1), x)); + return true; } static_assert(check_rvalue_lvalue_adl_swappable()); constexpr bool check_throwable_swappable() { auto x = throwable_adl_swappable{0}; auto y = throwable_adl_swappable{1}; - constexpr auto not_noexcept = !noexcept(std::ranges::swap(x, y)); - return check_swap_21(x, y) && not_noexcept; + ASSERT_NOT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_21(x, y)); + return true; } static_assert(check_throwable_swappable()); constexpr bool check_non_move_constructible_adl_swappable() { auto x = non_move_constructible_adl_swappable{0}; auto y = non_move_constructible_adl_swappable{1}; - constexpr auto is_noexcept = noexcept(std::ranges::swap(x, y)); - return check_swap_21(x, y) && is_noexcept; + ASSERT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_21(x, y)); + return true; } static_assert(check_non_move_constructible_adl_swappable()); constexpr bool check_non_move_assignable_adl_swappable() { auto x = non_move_assignable_adl_swappable{0}; auto y = non_move_assignable_adl_swappable{1}; - return check_swap_21(x, y) && noexcept(std::ranges::swap(x, y)); + ASSERT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_21(x, y)); + return true; } static_assert(check_non_move_assignable_adl_swappable()); @@ -136,43 +140,50 @@ constexpr bool check_swap_arrays() { int x[] = {0, 1, 2, 3, 4}; int y[] = {5, 6, 7, 8, 9}; - return check_swap_22(x, y) && noexcept(std::ranges::swap(x, y)); + ASSERT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_22(x, y)); + return true; } static_assert(check_swap_arrays()); constexpr bool check_lvalue_adl_swappable_arrays() { lvalue_adl_swappable x[] = {{0}, {1}, {2}, {3}}; lvalue_adl_swappable y[] = {{4}, {5}, {6}, {7}}; - return check_swap_22(x, y) && noexcept(std::ranges::swap(x, y)); + ASSERT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_22(x, y)); + return true; } static_assert(check_lvalue_adl_swappable_arrays()); constexpr bool check_throwable_adl_swappable_arrays() { throwable_adl_swappable x[] = {{0}, {1}, {2}, {3}}; throwable_adl_swappable y[] = {{4}, {5}, {6}, {7}}; - return check_swap_22(x, y) && !noexcept(std::ranges::swap(x, y)); + ASSERT_NOT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_22(x, y)); + return true; } static_assert(check_throwable_adl_swappable_arrays()); -inline auto global_x = 0; -static_assert(check_swap_23(0, 0) && - noexcept(std::ranges::swap(global_x, global_x))); -static_assert(check_swap_23(0, 1) && - noexcept(std::ranges::swap(global_x, global_x))); -static_assert(check_swap_23(1, 0) && - noexcept(std::ranges::swap(global_x, global_x))); +auto global_x = 0; +ASSERT_NOEXCEPT(std::ranges::swap(global_x, global_x)); +static_assert(check_swap_23(0, 0)); +static_assert(check_swap_23(0, 1)); +static_assert(check_swap_23(1, 0)); constexpr bool check_swappable_references() { int x = 42; int y = 64; - return check_swap_23(x, y) && noexcept(std::ranges::swap(x, y)); + ASSERT_NOEXCEPT(std::ranges::swap(x, y)); + assert(check_swap_23(x, y)); + return true; } static_assert(check_swappable_references()); constexpr bool check_swappable_pointers() { char const* x = "hello"; - return check_swap_23(x, nullptr) && - noexcept(std::ranges::swap(x, x)); + ASSERT_NOEXCEPT(std::ranges::swap(x, x)); + assert(check_swap_23(x, {})); + return true; } static_assert(check_swappable_pointers()); @@ -184,7 +195,7 @@ void swap(adl_swappable&, adl_swappable&); void swap(adl_swappable&&, adl_swappable&&); -}; // namespace union_swap +} // namespace union_swap static_assert(std::swappable); static_assert(std::swappable); static_assert(std::swappable); @@ -224,7 +235,9 @@ static_assert(std::assignable_from); static_assert(std::swappable); -template +enum class nothrow { no, yes }; + +template void check_swap(expected const& e) { auto a = e.y; auto b = e.x; @@ -237,7 +250,7 @@ assert(a == e.y); assert(b == e.x); - static_assert(noexcept(std::ranges::swap(a, b)) == is_noexcept); + static_assert(noexcept(std::ranges::swap(a, b)) == bool(is_noexcept)); } int main(int, char**) { @@ -246,42 +259,42 @@ .x = {6, 7, 8, 9}, .y = {0, 1, 2, 3, 4, 5}, }; - check_swap(e); + check_swap(e); } { auto const e = expected >{ .x = {{0, "whole"}, {1, "cashews"}}, .y = {{-1, "roasted"}, {2, "&"}, {-3, "salted"}}, }; - check_swap(e); + check_swap(e); } { auto const e = expected{ .x = "hello there", .y = "general kenobi", }; - check_swap(e); + check_swap(e); } { auto const e = expected >{ .x = {10}, .y = {20}, }; - check_swap(e); + check_swap(e); } { auto const e = expected >{ .x = {10}, .y = {20}, }; - check_swap(e); + check_swap(e); } { auto const e = expected >{ .x = {{0, "whole"}, {1, "cashews"}}, .y = {{-1, "roasted"}, {2, "&"}, {-3, "salted"}}, }; - check_swap(e); + check_swap(e); } { auto const e = expected >{ @@ -289,7 +302,7 @@ .y = {6, 7, 8, 9}, }; - check_swap(e); + check_swap(e); } return 0; } diff --git a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp --- 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 @@ -21,12 +21,12 @@ constexpr Sink(Sink*) {} }; -constexpr int count(std::span sp) { +constexpr size_t count(std::span sp) { return sp.size(); } template -constexpr int countn(std::span sp) { +constexpr size_t countn(std::span sp) { return sp.size(); } diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/cxx20_iter_member.pass.cpp @@ -22,16 +22,26 @@ struct NoIteratorAlias { double data_[3] = {}; - using value_type = int; double *begin(); - constexpr double *insert(double *pos, int value) { + + struct value_type { + constexpr value_type(double d) : x(static_cast(d)) {} + constexpr operator double() const { return x; } + + int x; + }; + + template + constexpr double *insert(double *pos, T value) { + static_assert(std::is_same_v); *pos = value; return pos; } }; static_assert(std::is_constructible_v, NoIteratorAlias&, double*>); -static_assert(!std::is_constructible_v, NoIteratorAlias&, int*>); +static_assert( + !std::is_constructible_v, NoIteratorAlias&, NoIteratorAlias::value_type*>); constexpr bool test() { NoIteratorAlias c; 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 @@ -41,8 +41,10 @@ return {static_cast(0x60AF8503), static_cast(0x0385AF60)}; case 8: return {static_cast(0xABCDFE9477936406), static_cast(0x0664937794FECDAB)}; + default: + assert(false); + return {}; // for MSVC, whose `assert` is tragically not [[noreturn]] } - assert(false); } template @@ -57,8 +59,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 +73,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,8 @@ } { const std::ranges::iota_view io(0, std::numeric_limits::max()); - assert(io.size() == std::numeric_limits::max()); + constexpr auto imax = std::numeric_limits::max(); + assert(io.size() == imax); } // Neither are integer like. diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp @@ -13,6 +13,7 @@ // template // void resize_and_overwrite(size_type n, Operation op) +#include #include #include 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,11 +35,11 @@ void test_exception() { [] { std::format_parse_context context("", 1); - context.next_arg_id(); + TEST_IGNORE_NODISCARD context.next_arg_id(); try { context.check_arg_id(0); assert(false); - } catch (const std::format_error& e) { + } catch ([[maybe_unused]] const std::format_error& e) { LIBCPP_ASSERT(strcmp(e.what(), "Using manual argument numbering in automatic " "argument numbering mode") == 0); return; diff --git a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp --- a/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp +++ b/libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/next_arg_id.pass.cpp @@ -37,9 +37,9 @@ context.check_arg_id(0); try { - context.next_arg_id(); + TEST_IGNORE_NODISCARD context.next_arg_id(); assert(false); - } catch (const std::format_error& e) { + } catch ([[maybe_unused]] const std::format_error& e) { LIBCPP_ASSERT(strcmp(e.what(), "Using automatic argument numbering in manual " "argument numbering mode") == 0); return; diff --git a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/format.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/format.pass.cpp @@ -67,11 +67,10 @@ return; } assert(false); -#else +#endif (void)what; (void)fmt; (void)sizeof...(args); -#endif }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/format_tests.h b/libcxx/test/std/utilities/format/format.functions/format_tests.h --- a/libcxx/test/std/utilities/format/format.functions/format_tests.h +++ b/libcxx/test/std/utilities/format/format.functions/format_tests.h @@ -165,7 +165,7 @@ STR("hello {:{}}"), world, -1); check_exception( "A format-spec arg-id replacement exceeds the maximum supported value", - STR("hello {:{}}"), world, -1u); + STR("hello {:{}}"), world, unsigned(-1)); check_exception("Argument index out of bounds", STR("hello {:{}}"), world); check_exception( "A format-spec arg-id replacement argument isn't an integral type", @@ -201,7 +201,7 @@ 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,18 @@ 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...)); + (void) std::vformat(std::locale(), fmt, + std::make_format_args>(args...)); assert(false); - } catch (std::format_error& e) { + } catch ([[maybe_unused]] std::format_error& e) { LIBCPP_ASSERT(e.what() == what); return; } assert(false); -#else +#endif (void)what; (void)fmt; (void)sizeof...(args); -#endif }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/vformat.pass.cpp @@ -35,18 +35,17 @@ 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) { + } catch ([[maybe_unused]] std::format_error& e) { LIBCPP_ASSERT(e.what() == what); return; } assert(false); -#else +#endif (void)what; (void)fmt; (void)sizeof...(args); -#endif }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.locale.pass.cpp @@ -74,16 +74,15 @@ std::vformat_to(std::back_inserter(out), std::locale(), fmt, std::make_format_args>(args...)); assert(false); - } catch (std::format_error& e) { + } catch ([[maybe_unused]] std::format_error& e) { LIBCPP_ASSERT(e.what() == what); return; } assert(false); -#else +#endif (void)what; (void)fmt; (void)sizeof...(args); -#endif }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp --- a/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp +++ b/libcxx/test/std/utilities/format/format.functions/vformat_to.pass.cpp @@ -74,16 +74,15 @@ std::vformat_to(std::back_inserter(out), fmt, std::make_format_args>(args...)); assert(false); - } catch (std::format_error& e) { + } catch ([[maybe_unused]] std::format_error& e) { LIBCPP_ASSERT(e.what() == what); return; } assert(false); -#else +#endif (void)what; (void)fmt; (void)sizeof...(args); -#endif }; int main(int, char**) { diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/explicit_const_optional_U.pass.cpp @@ -73,9 +73,9 @@ { int i_; public: - constexpr explicit Z(int i) : i_(i) { TEST_THROW(6);} + explicit Z(int i) : i_(i) {TEST_THROW(6);} - friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} + friend bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} }; template 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()() const { assert(false); return false; } }; Callable __impl; diff --git a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp --- 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 { assert(false); return false; } }; 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); }