Skip to content

Commit

Permalink
[libc++] Fix name of is_always_lock_free test which was never being r…
Browse files Browse the repository at this point in the history
…un (#106077)
  • Loading branch information
ldionne authored Oct 2, 2024
1 parent 6d6eea9 commit b456619
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//

// UNSUPPORTED: c++03, c++11, c++14
// XFAIL: LIBCXX-PICOLIBC-FIXME

// <atomic>
//
Expand All @@ -15,6 +16,10 @@
//
// static constexpr bool is_always_lock_free;

// Ignore diagnostic about vector types changing the ABI on some targets, since
// that is irrelevant for this test.
// ADDITIONAL_COMPILE_FLAGS: -Wno-psabi

#include <atomic>
#include <cassert>
#include <concepts>
Expand All @@ -27,7 +32,8 @@ template <typename T>
void check_always_lock_free(std::atomic<T> const& a) {
using InfoT = LockFreeStatusInfo<T>;

constexpr std::same_as<const bool> decltype(auto) is_always_lock_free = std::atomic<T>::is_always_lock_free;
constexpr auto is_always_lock_free = std::atomic<T>::is_always_lock_free;
ASSERT_SAME_TYPE(decltype(is_always_lock_free), bool const);

// If we know the status of T for sure, validate the exact result of the function.
if constexpr (InfoT::status_known) {
Expand All @@ -45,7 +51,8 @@ void check_always_lock_free(std::atomic<T> const& a) {

// In all cases, also sanity-check it based on the implication always-lock-free => lock-free.
if (is_always_lock_free) {
std::same_as<bool> decltype(auto) is_lock_free = a.is_lock_free();
auto is_lock_free = a.is_lock_free();
ASSERT_SAME_TYPE(decltype(is_always_lock_free), bool const);
assert(is_lock_free);
}
ASSERT_NOEXCEPT(a.is_lock_free());
Expand Down

0 comments on commit b456619

Please sign in to comment.