[all-commits] [llvm/llvm-project] 266fac: [libc++] [test] Fix MSVC warnings (#93257)

Stephan T. Lavavej via All-commits all-commits at lists.llvm.org
Tue May 28 12:18:19 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 266fac8375bdf3f039503c559bb16ffab8895ae5
      https://github.com/llvm/llvm-project/commit/266fac8375bdf3f039503c559bb16ffab8895ae5
  Author: Stephan T. Lavavej <stl at nuwen.net>
  Date:   2024-05-28 (Tue, 28 May 2024)

  Changed paths:
    M libcxx/test/std/atomics/atomics.ref/compare_exchange_strong.pass.cpp
    M libcxx/test/std/atomics/atomics.ref/compare_exchange_weak.pass.cpp
    M libcxx/test/std/atomics/atomics.ref/wait.pass.cpp
    M libcxx/test/std/containers/views/views.span/span.cons/initializer_list.pass.cpp
    M libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
    M libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
    M libcxx/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
    M libcxx/test/support/msvc_stdlib_force_include.h

  Log Message:
  -----------
  [libc++] [test] Fix MSVC warnings (#93257)

Found while running libc++'s tests with MSVC's STL.

* Avoid MSVC warning C5101: use of preprocessor directive in
function-like macro argument list is undefined behavior.
+ We can easily make this portable by extracting `const bool is_newlib`.
  + Followup to #73440.
  + See #73598.
  + See #73836.
* Avoid MSVC warning C4267: 'return': conversion from 'size_t' to 'int',
possible loss of data.
+ This warning is valid, but harmless for the test, so
`static_cast<int>` will avoid it.
* Avoid MSVC warning C4146: unary minus operator applied to unsigned
type, result still unsigned.
+ This warning is also valid (the scenario is sometimes intentional, but
surprising enough that it's worth warning about). This is a C++17 test,
so we can easily avoid it by testing `is_signed_v` at compile-time
before testing `m < 0` and `n < 0` at run-time.
* Silence MSVC warning C4310: cast truncates constant value.
+ These warnings are being emitted by `T(255)`. Disabling the warning is
simpler than attempting to restructure the code.
  + Followup to #79791.
* MSVC no longer emits warning C4521: multiple copy constructors
specified.
+ This warning was removed from the compiler, since at least 2021-12-09.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list