[libc++][test] Fix msvc_is_lock_free_macro_value()#105876
Merged
StephanTLavavej merged 2 commits intollvm:mainfrom Aug 24, 2024
Merged
[libc++][test] Fix msvc_is_lock_free_macro_value()#105876StephanTLavavej merged 2 commits intollvm:mainfrom
msvc_is_lock_free_macro_value()#105876StephanTLavavej merged 2 commits intollvm:mainfrom
Conversation
Followup to LLVM-99570. Fixes: llvm-project\libcxx\test\support\atomic_helpers.h(33): fatal error C1017: invalid integer constant expression
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.
Member
|
@llvm/pr-subscribers-libcxx Author: Stephan T. Lavavej (StephanTLavavej) ChangesFollowup to #99570.
Full diff: https://github.com/llvm/llvm-project/pull/105876.diff 1 Files Affected:
diff --git a/libcxx/test/support/atomic_helpers.h b/libcxx/test/support/atomic_helpers.h
index d2f2b751cb47de..2b3a3caa06a589 100644
--- a/libcxx/test/support/atomic_helpers.h
+++ b/libcxx/test/support/atomic_helpers.h
@@ -30,15 +30,15 @@
# 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.
//
// Note MSVC's STL never produces a type that is sometimes lock free, but not always lock free.
template <class T, size_t Size = sizeof(T)>
-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<char>()
# define TEST_ATOMIC_SHORT_LOCK_FREE ::msvc_is_lock_free_macro_value<short>()
|
philnik777
approved these changes
Aug 24, 2024
Member
Author
|
Thanks! I'll go ahead and merge this as all of the GH checks have passed, and all of the BuildKite checks except that 4 Apple configurations have been waiting for agents for 21 hours - my changes are very clearly limited to MSVC so there should be no concern there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Followup to #99570.
TEST_COMPILER_MSVCmust be tested fordefinedness, as it is everywhere else.llvm-project/libcxx/test/support/test_macros.h
Lines 71 to 72 in 52a7116
llvm-project/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
Line 248 in 52a7116
llvm-project\libcxx\test\support\atomic_helpers.h(33): fatal error C1017: invalid integer constant expressionmsvc_is_lock_free_macro_value()returns2or0, so it needs to returnint.llvm-project\libcxx\test\support\atomic_helpers.h(41): warning C4305: 'return': truncation from 'int' to 'bool'