Implement P0558R2 changes to std::atomic

Programming / Compilers / GCC - redi [138bc75d-0d04-0410-961f-82ee72b054a4] - 24 May 2018 15:28 EDT

The restrictions forbidding arithmetic on atomic pointer types are only enabled for C++17 and later, retaining the GNU extension for older standards. The new nested typedefs and changes to prevent scalar parameters participating in template argument deduction are enabled unconditionally.

PR libstdc++/69769 PR libstdc++/85886
- include/bits/atomic_base.h (__atomic_base::value_type) (__atomic_base::difference_type): Add new typedefs.
- include/std/atomic (atomic::value_type, atomic::value_type) (atomic::value_type, atomic::difference_type): Likewise. (atomic::operator++, atomic::operator--) (atomic::operator+=, atomic::operator-=) (atomic::fetch_add, atomic::fetch_sub): Add static assertion to enforce C++17 requirement on pointer arithmetic. (__atomic_val_t, __atomic_diff_t): New alias templates. (atomic_init, atomic_store_explicit, atomic_exchange_explicit) (atomic_compare_exchange_weak_explicit) (atomic_compare_exchange_strong_explicit, atomic_store) (atomic_exchange, atomic_compare_exchange_weak) (atomic_compare_exchange_strong): Use __atomic_val_t to make scalar parameters be non-deduced contexts. (atomic_fetch_add_explicit, atomic_fetch_sub_explicit) (atomic_fetch_add, atomic_fetch_sub): Change first parameter to be atomic instead of __atomic_base, and use __atomic_diff_t for scalar parameters. (atomic_fetch_and_explicit, atomic_fetch_or_explicit) (atomic_fetch_xor_explicit, atomic_fetch_and, atomic_fetch_or) (atomic_fetch_xor): Use __atomic_val_t for scalar parameters. (atomic_fetch_add_explicit, atomic_fetch_sub_explicit) (atomic_fetch_add, atomic_fetch_sub): Remove overloads for atomic address types.
- testsuite/29_atomics/atomic/60695.cc: Adjust dg-error lineno.
- testsuite/29_atomics/atomic/69769.cc: New test.
- testsuite/29_atomics/atomic/nonmembers.cc: New test.
- testsuite/29_atomics/atomic/operators/pointer_partial_void.cc: Disable test for C++17 and later.
- testsuite/29_atomics/atomic/requirements/typedefs.cc: New test.
- testsuite/29_atomics/atomic_integral/nonmembers.cc: New test.
- testsuite/29_atomics/atomic_integral/requirements/typedefs.cc: New test.

4ea6fc6b117 Implement P0558R2 changes to std::atomic
libstdc++-v3/ChangeLog | 39 +++
libstdc++-v3/include/bits/atomic_base.h | 3 +
libstdc++-v3/include/std/atomic | 320 +++++++++++++--------
libstdc++-v3/testsuite/29_atomics/atomic/60695.cc | 2 +-
libstdc++-v3/testsuite/29_atomics/atomic/69769.cc | 80 ++++++
.../testsuite/29_atomics/atomic/nonmembers.cc | 230 +++++++++++++++
.../atomic/operators/pointer_partial_void.cc | 2 +-
.../29_atomics/atomic/requirements/typedefs.cc | 36 +++
.../29_atomics/atomic_integral/nonmembers.cc | 163 +++++++++++
.../atomic_integral/requirements/typedefs.cc | 39 +++
10 files changed, 791 insertions(+), 123 deletions(-)

Upstream: gcc.gnu.org


  • Share