diff --git a/libcxx/test/std/atomics/atomics.ref/compare_exchange_strong.pass.cpp b/libcxx/test/std/atomics/atomics.ref/compare_exchange_strong.pass.cpp index 72b2f444c476c..90aa5ea5b6df4 100644 --- a/libcxx/test/std/atomics/atomics.ref/compare_exchange_strong.pass.cpp +++ b/libcxx/test/std/atomics/atomics.ref/compare_exchange_strong.pass.cpp @@ -9,6 +9,9 @@ // XFAIL: !has-64-bit-atomics // XFAIL: !has-1024-bit-atomics +// MSVC warning C4310: cast truncates constant value +// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4310 + // bool compare_exchange_strong(T&, T, memory_order, memory_order) const noexcept; // bool compare_exchange_strong(T&, T, memory_order = memory_order::seq_cst) const noexcept; diff --git a/libcxx/test/std/atomics/atomics.ref/compare_exchange_weak.pass.cpp b/libcxx/test/std/atomics/atomics.ref/compare_exchange_weak.pass.cpp index 5219a8e3714f9..99c1385a2fe0b 100644 --- a/libcxx/test/std/atomics/atomics.ref/compare_exchange_weak.pass.cpp +++ b/libcxx/test/std/atomics/atomics.ref/compare_exchange_weak.pass.cpp @@ -9,6 +9,9 @@ // XFAIL: !has-64-bit-atomics // XFAIL: !has-1024-bit-atomics +// MSVC warning C4310: cast truncates constant value +// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4310 + // bool compare_exchange_weak(T&, T, memory_order, memory_order) const noexcept; // bool compare_exchange_weak(T&, T, memory_order = memory_order::seq_cst) const noexcept; diff --git a/libcxx/test/std/atomics/atomics.ref/wait.pass.cpp b/libcxx/test/std/atomics/atomics.ref/wait.pass.cpp index e5310febf5c5e..f246803ba2592 100644 --- a/libcxx/test/std/atomics/atomics.ref/wait.pass.cpp +++ b/libcxx/test/std/atomics/atomics.ref/wait.pass.cpp @@ -11,6 +11,9 @@ // XFAIL: !has-64-bit-atomics // XFAIL: !has-1024-bit-atomics +// MSVC warning C4310: cast truncates constant value +// ADDITIONAL_COMPILE_FLAGS(cl-style-warnings): /wd4310 + // void wait(T, memory_order = memory_order::seq_cst) const noexcept; #include diff --git a/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp index 74a5094f61261..bc76e23fea3c0 100644 --- a/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp +++ b/libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp @@ -93,9 +93,9 @@ constexpr bool test() { // Test P2447R4 "Annex C examples" -constexpr int three(std::span sp) { return sp.size(); } +constexpr int three(std::span sp) { return static_cast(sp.size()); } -constexpr int four(std::span sp) { return sp.size(); } +constexpr int four(std::span sp) { return static_cast(sp.size()); } bool test_P2447R4_annex_c_examples() { // 1. Overload resolution is affected diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp index d4bbde75ae882..7283fdc769d86 100644 --- a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp @@ -50,13 +50,16 @@ int main(int, char**) // responds with an empty message, which we probably want to // treat as a failure code otherwise, but we can detect that // with the preprocessor. +#if defined(_NEWLIB_VERSION) + const bool is_newlib = true; +#else + const bool is_newlib = false; +#endif + (void)is_newlib; LIBCPP_ASSERT(msg.rfind("Error -1 occurred", 0) == 0 // AIX || msg.rfind("No error information", 0) == 0 // Musl || msg.rfind("Unknown error", 0) == 0 // Glibc -#if defined(_NEWLIB_VERSION) - || msg.empty() -#endif - ); + || (is_newlib && msg.empty())); assert(errno == E2BIG); } diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp index eefbddd27a7f5..02a1baf599983 100644 --- a/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp +++ b/libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp @@ -56,13 +56,16 @@ int main(int, char**) { // responds with an empty message, which we probably want to // treat as a failure code otherwise, but we can detect that // with the preprocessor. +#if defined(_NEWLIB_VERSION) + const bool is_newlib = true; +#else + const bool is_newlib = false; +#endif + (void)is_newlib; LIBCPP_ASSERT(msg.rfind("Error -1 occurred", 0) == 0 // AIX || msg.rfind("No error information", 0) == 0 // Musl || msg.rfind("Unknown error", 0) == 0 // Glibc -#if defined(_NEWLIB_VERSION) - || msg.empty() -#endif - ); + || (is_newlib && msg.empty())); assert(errno == E2BIG); } diff --git a/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp b/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp index 212804356a056..bf40b174b209c 100644 --- a/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp @@ -57,10 +57,12 @@ T basic_gcd_(T m, T n) { template T basic_gcd(T m, T n) { using Tp = std::make_unsigned_t; - if (m < 0 && m != std::numeric_limits::min()) - m = -m; - if (n < 0 && n != std::numeric_limits::min()) - n = -n; + if constexpr (std::is_signed_v) { + if (m < 0 && m != std::numeric_limits::min()) + m = -m; + if (n < 0 && n != std::numeric_limits::min()) + n = -n; + } return basic_gcd_(static_cast(m), static_cast(n)); } diff --git a/libcxx/test/support/msvc_stdlib_force_include.h b/libcxx/test/support/msvc_stdlib_force_include.h index 6c26085e72c45..35783c1607b0e 100644 --- a/libcxx/test/support/msvc_stdlib_force_include.h +++ b/libcxx/test/support/msvc_stdlib_force_include.h @@ -67,7 +67,6 @@ const AssertionDialogAvoider assertion_dialog_avoider{}; // Silence compiler warnings. # pragma warning(disable : 4180) // qualifier applied to function type has no meaning; ignored # pragma warning(disable : 4324) // structure was padded due to alignment specifier -# pragma warning(disable : 4521) // multiple copy constructors specified # pragma warning(disable : 4702) // unreachable code # pragma warning(disable : 28251) // Inconsistent annotation for 'new': this instance has no annotations. #endif // !defined(__clang__)