From 31cdf1163d48b51b17b36927fbd96bd8b92a2753 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 23 Aug 2024 12:01:33 -0700 Subject: [PATCH 1/2] Test defined(TEST_COMPILER_MSVC). Followup to LLVM-99570. Fixes: llvm-project\libcxx\test\support\atomic_helpers.h(33): fatal error C1017: invalid integer constant expression --- libcxx/test/support/atomic_helpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/test/support/atomic_helpers.h b/libcxx/test/support/atomic_helpers.h index d2f2b751cb47d..6b1bd55787f92 100644 --- a/libcxx/test/support/atomic_helpers.h +++ b/libcxx/test/support/atomic_helpers.h @@ -30,7 +30,7 @@ # define TEST_ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE # define TEST_ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE # define TEST_ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE -#elif TEST_COMPILER_MSVC +#elif defined(TEST_COMPILER_MSVC) // This is lifted from STL/stl/inc/atomic on github for the purposes of // keeping the tests compiling for MSVC's STL. It's not a perfect solution // but at least the tests will keep running. From a0a387a43f075a4a4ab1ea3e0201f8416238aa2a Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 23 Aug 2024 12:11:46 -0700 Subject: [PATCH 2/2] Fix bogus return type. Fixes: llvm-project\libcxx\test\support\atomic_helpers.h(41): warning C4305: 'return': truncation from 'int' to 'bool' For clarity, also add parens when mixing bitwise with arithmetic operators. --- libcxx/test/support/atomic_helpers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcxx/test/support/atomic_helpers.h b/libcxx/test/support/atomic_helpers.h index 6b1bd55787f92..2b3a3caa06a58 100644 --- a/libcxx/test/support/atomic_helpers.h +++ b/libcxx/test/support/atomic_helpers.h @@ -37,8 +37,8 @@ // // Note MSVC's STL never produces a type that is sometimes lock free, but not always lock free. template -constexpr bool msvc_is_lock_free_macro_value() { - return (Size <= 8 && (Size & Size - 1) == 0) ? 2 : 0; +constexpr int msvc_is_lock_free_macro_value() { + return (Size <= 8 && (Size & (Size - 1)) == 0) ? 2 : 0; } # define TEST_ATOMIC_CHAR_LOCK_FREE ::msvc_is_lock_free_macro_value() # define TEST_ATOMIC_SHORT_LOCK_FREE ::msvc_is_lock_free_macro_value()