diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp index ce5cf0560fc81..b1ad6873bc5e5 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move.pass.cpp @@ -94,7 +94,7 @@ struct Test1OutIters { TEST_CONSTEXPR_CXX20 bool test() { types::for_each(types::cpp17_input_iterator_list(), TestOutIters()); - if (TEST_STD_VER >= 23 || !TEST_IS_CONSTANT_EVALUATED) + if (TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED) types::for_each(types::cpp17_input_iterator_list*>(), Test1OutIters()); { // Make sure that padding bits aren't copied diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp index 2ed4d37b9dbe6..61dea47b51071 100644 --- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp +++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp @@ -92,7 +92,7 @@ struct Test1OutIters { TEST_CONSTEXPR_CXX20 bool test() { types::for_each(types::bidirectional_iterator_list(), TestOutIters()); - if (TEST_STD_VER >= 23 || !TEST_IS_CONSTANT_EVALUATED) + if (TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED) types::for_each(types::bidirectional_iterator_list*>(), Test1OutIters()); { // Make sure that padding bits aren't copied diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp index cc832febdba75..904100c1cf0bb 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.count/count.pass.cpp @@ -38,7 +38,7 @@ struct Test { TEST_CONSTEXPR_CXX20 bool test() { types::for_each(types::cpp17_input_iterator_list(), Test()); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { std::vector vec(256 + 64); for (ptrdiff_t i = 0; i != 256; ++i) { for (size_t offset = 0; offset != 64; ++offset) { diff --git a/libcxx/test/std/containers/views/mdspan/ConvertibleToIntegral.h b/libcxx/test/std/containers/views/mdspan/ConvertibleToIntegral.h index 470f5d8e72464..0ca5c330a390e 100644 --- a/libcxx/test/std/containers/views/mdspan/ConvertibleToIntegral.h +++ b/libcxx/test/std/containers/views/mdspan/ConvertibleToIntegral.h @@ -16,8 +16,8 @@ struct IntType { constexpr bool operator==(const IntType& rhs) const { return val == rhs.val; } constexpr operator int() const noexcept { return val; } - constexpr operator unsigned char() const { return val; } - constexpr operator signed char() const noexcept { return val; } + constexpr operator unsigned char() const { return static_cast(val); } + constexpr operator signed char() const noexcept { return static_cast(val); } }; // only non-const convertible @@ -28,8 +28,8 @@ struct IntTypeNC { constexpr bool operator==(const IntType& rhs) const { return val == rhs.val; } constexpr operator int() noexcept { return val; } - constexpr operator unsigned() { return val; } - constexpr operator char() noexcept { return val; } + constexpr operator unsigned() { return static_cast(val); } + constexpr operator char() noexcept { return static_cast(val); } }; // weird configurability of convertibility to int diff --git a/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp b/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp index a2d46ab1b94c7..796ab41716dd5 100644 --- a/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp @@ -61,6 +61,7 @@ void check_random_device_invalid(const std::string &token) { int main(int, char**) { { std::random_device r; + (void)r; } // Check the validity of various tokens { diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp index 4f00bd7f6edf1..fc99df4072131 100644 --- a/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/equal.pass.cpp @@ -51,7 +51,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((ConvertibleTo(v[i]) == v[j]) == expected); assert((v[i] == ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(v[i]) == v[j]) == expected); assert((v[i] == std::basic_string(v[j])) == expected); } @@ -72,7 +72,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((abc.data() == abc0def) == false); assert((abc0def == abc.data()) == false); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(abc) == abc0def) == false); assert((abc0def == std::basic_string(abc)) == false); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp index b965c155ec51b..fd3a438167994 100644 --- a/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/greater.pass.cpp @@ -51,7 +51,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((ConvertibleTo(v[i]) > v[j]) == expected); assert((v[i] > ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(v[i]) > v[j]) == expected); assert((v[i] > std::basic_string(v[j])) == expected); } @@ -72,7 +72,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((abc.data() > abc0def) == false); assert((abc0def > abc.data()) == true); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(abc) > abc0def) == false); assert((abc0def > std::basic_string(abc)) == true); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp index 435e7db773199..0d9081e1c01d8 100644 --- a/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/greater_equal.pass.cpp @@ -51,7 +51,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((ConvertibleTo(v[i]) >= v[j]) == expected); assert((v[i] >= ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(v[i]) >= v[j]) == expected); assert((v[i] >= std::basic_string(v[j])) == expected); } @@ -72,7 +72,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((abc.data() >= abc0def) == false); assert((abc0def >= abc.data()) == true); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(abc) >= abc0def) == false); assert((abc0def >= std::basic_string(abc)) == true); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp index 7461b05ce3085..bb61b1df193e6 100644 --- a/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/less.pass.cpp @@ -51,7 +51,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((ConvertibleTo(v[i]) < v[j]) == expected); assert((v[i] < ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(v[i]) < v[j]) == expected); assert((v[i] < std::basic_string(v[j])) == expected); } @@ -72,7 +72,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((abc.data() < abc0def) == true); assert((abc0def < abc.data()) == false); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(abc) < abc0def) == true); assert((abc0def < std::basic_string(abc)) == false); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp index 3192db0dc7d7d..d91e112d6dabf 100644 --- a/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/less_equal.pass.cpp @@ -51,7 +51,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((ConvertibleTo(v[i]) <= v[j]) == expected); assert((v[i] <= ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(v[i]) <= v[j]) == expected); assert((v[i] <= std::basic_string(v[j])) == expected); } @@ -72,7 +72,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((abc.data() <= abc0def) == true); assert((abc0def <= abc.data()) == false); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(abc) <= abc0def) == true); assert((abc0def <= std::basic_string(abc)) == false); } diff --git a/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp b/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp index 0082a56839331..a4c8be9f878f0 100644 --- a/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.comparison/not_equal.pass.cpp @@ -51,7 +51,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((ConvertibleTo(v[i]) != v[j]) == expected); assert((v[i] != ConvertibleTo(v[j])) == expected); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(v[i]) != v[j]) == expected); assert((v[i] != std::basic_string(v[j])) == expected); } @@ -72,7 +72,7 @@ TEST_CONSTEXPR_CXX14 bool test() { assert((abc.data() != abc0def) == true); assert((abc0def != abc.data()) == true); - if (!TEST_IS_CONSTANT_EVALUATED || TEST_STD_VER >= 20) { + if (TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED) { assert((std::basic_string(abc) != abc0def) == true); assert((abc0def != std::basic_string(abc)) == true); } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp index 48a96f90254e3..f953fa4f8d6df 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/mutex.pass.cpp @@ -66,6 +66,7 @@ int main(int, char**) { using LG = std::scoped_lock<>; LG lg; + (void)lg; } { using LG = std::scoped_lock; diff --git a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp index 91320a52b62ae..5504645bb31f9 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/default.pass.cpp @@ -22,6 +22,7 @@ int main(int, char**) { std::shared_mutex m; + (void)m; - return 0; + return 0; } diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index f3c6d8080ff6d..02678d987d265 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -151,6 +151,18 @@ # define TEST_IS_CONSTANT_EVALUATED false #endif +#if TEST_STD_VER >= 23 +# define TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED true +#else +# define TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED (!TEST_IS_CONSTANT_EVALUATED) +#endif + +#if TEST_STD_VER >= 20 +# define TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED true +#else +# define TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED (!TEST_IS_CONSTANT_EVALUATED) +#endif + #if TEST_STD_VER >= 14 # define TEST_CONSTEXPR_CXX14 constexpr #else