diff --git a/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp b/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp --- a/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp +++ b/libcxx/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp @@ -29,38 +29,25 @@ assert(std::atomic().is_lock_free()); } -// FIXME: This separate test is needed to work around llvm.org/PR31864 -// which causes ATOMIC_LLONG_LOCK_FREE to be defined as '1' in 32-bit builds -// even though __atomic_always_lock_free returns true for the same type. -constexpr bool NeedWorkaroundForPR31864 = -#if defined(__clang__) -(sizeof(void*) == 4); // Needed on 32 bit builds +void checkLongLongTypes() { + static_assert(std::atomic::is_always_lock_free == __atomic_always_lock_free(sizeof(long long), 0), ""); + static_assert(std::atomic::is_always_lock_free == + __atomic_always_lock_free(sizeof(unsigned long long), 0), + ""); +// This looks like a GCC bug, it failed with static_assert, but succeeded with assert. +#ifdef __GNUC__ + assert(__atomic_always_lock_free(sizeof(long long), (long long*)alignof(long long)) == (2 == ATOMIC_LLONG_LOCK_FREE)); + assert(__atomic_always_lock_free(sizeof(unsigned long long), (unsigned long long*)alignof(unsigned long long)) == + (2 == ATOMIC_LLONG_LOCK_FREE)); #else -false; + static_assert(__atomic_always_lock_free(sizeof(long long), (long long*)alignof(long long)) == + (2 == ATOMIC_LLONG_LOCK_FREE), + ""); + static_assert( + __atomic_always_lock_free(sizeof(unsigned long long), (unsigned long long*)alignof(unsigned long long)) == + (2 == ATOMIC_LLONG_LOCK_FREE), + ""); #endif - -template * = nullptr, - class LLong = long long, - class ULLong = unsigned long long> -void checkLongLongTypes() { - static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE), ""); - static_assert(std::atomic::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE), ""); -} - -// Used to make the calls to __atomic_always_lock_free dependent on a template -// parameter. -template constexpr size_t getSizeOf() { return sizeof(T); } - -template * = nullptr, - class LLong = long long, - class ULLong = unsigned long long> -void checkLongLongTypes() { - constexpr bool ExpectLockFree = __atomic_always_lock_free(getSizeOf(), 0); - static_assert(std::atomic::is_always_lock_free == ExpectLockFree, ""); - static_assert(std::atomic::is_always_lock_free == ExpectLockFree, ""); - static_assert((0 != ATOMIC_LLONG_LOCK_FREE) == ExpectLockFree, ""); } void run()