Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand std::atomic feature tests to include compare_exchange, fetch_add, etc. #1315

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions cmake/tests/cxx11_std_atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,34 @@
void test_atomic()
{
std::atomic<T> a;

a.store(T{});
T i = a.load();
(void) i;

{
[[maybe_unused]] T i = a.load();

Check notice on line 20 in cmake/tests/cxx11_std_atomic.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cmake/tests/cxx11_std_atomic.cpp#L20

Variable 'i' is assigned a value that is never used.
}

{
[[maybe_unused]] T i = a.exchange(T{});

Check notice on line 24 in cmake/tests/cxx11_std_atomic.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cmake/tests/cxx11_std_atomic.cpp#L24

Variable 'i' is assigned a value that is never used.
}

{
T expected{};
[[maybe_unused]] bool b = a.compare_exchange_weak(expected, T{});
}

{
T expected{};
[[maybe_unused]] bool b = a.compare_exchange_strong(expected, T{});
}

{
[[maybe_unused]] T i = a.fetch_sub(T{1});

Check notice on line 38 in cmake/tests/cxx11_std_atomic.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cmake/tests/cxx11_std_atomic.cpp#L38

Variable 'i' is assigned a value that is never used.
}

{
[[maybe_unused]] T i = a.fetch_add(T{1});

Check notice on line 42 in cmake/tests/cxx11_std_atomic.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cmake/tests/cxx11_std_atomic.cpp#L42

Variable 'i' is assigned a value that is never used.
}
}

int main()
Expand Down
21 changes: 19 additions & 2 deletions cmake/tests/cxx11_std_atomic_128bit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,26 @@
void test_atomic()
{
std::atomic<T> a;

a.store(T{});
T i = a.load();
(void) i;

{
[[maybe_unused]] T i = a.load();

Check notice on line 20 in cmake/tests/cxx11_std_atomic_128bit.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cmake/tests/cxx11_std_atomic_128bit.cpp#L20

Variable 'i' is assigned a value that is never used.
}

{
[[maybe_unused]] T i = a.exchange(T{});

Check notice on line 24 in cmake/tests/cxx11_std_atomic_128bit.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cmake/tests/cxx11_std_atomic_128bit.cpp#L24

Variable 'i' is assigned a value that is never used.
}

{
T expected{};
[[maybe_unused]] bool b = a.compare_exchange_weak(expected, T{});
}

{
T expected{};
[[maybe_unused]] bool b = a.compare_exchange_strong(expected, T{});
}
}

struct uint128_type
Expand Down
Loading