Skip to content

Commit 3cfa32a

Browse files
committed
Undeprecate ATOMIC_FLAG_INIT in C++
C++20 deprecated ATOMIC_FLAG_INIT thinking it was deprecated in C when it wasn't. It is expected to be undeprecated in C++23 as part of LWG3659 (https://wg21.link/LWG3659), which is currently Tentatively Ready. This handles the case where the user includes <stdatomic.h> in C++ code in a freestanding compile mode. The corollary libc++ changes are in 1544d1f.
1 parent 81af344 commit 3cfa32a

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ C++2b Feature Support
486486
- Implemented `P2128R6: Multidimensional subscript operator <https://wg21.link/P2128R6>`_.
487487
- Implemented `P0849R8: auto(x): decay-copy in the language <https://wg21.link/P0849R8>`_.
488488
- Implemented `P2242R3: Non-literal variables (and labels and gotos) in constexpr functions <https://wg21.link/P2242R3>`_.
489+
- Implemented `LWG3659: Consider ATOMIC_FLAG_INIT undeprecation <https://wg21.link/LWG3659>`_.
489490

490491
CUDA/HIP Language Changes in Clang
491492
----------------------------------

clang/lib/Headers/stdatomic.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,6 @@ typedef _Atomic(uintmax_t) atomic_uintmax_t;
158158
typedef struct atomic_flag { atomic_bool _Value; } atomic_flag;
159159

160160
#define ATOMIC_FLAG_INIT { 0 }
161-
#if __cplusplus >= 202002L && !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
162-
/* ATOMIC_FLAG_INIT was deprecated in C++20 but is not deprecated in C. */
163-
#pragma clang deprecated(ATOMIC_FLAG_INIT)
164-
#endif
165161

166162
/* These should be provided by the libc implementation. */
167163
#ifdef __cplusplus

clang/test/Headers/stdatomic-deprecations.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
void func(void) {
1313
_Atomic int i = ATOMIC_VAR_INIT(12); // expected-warning {{macro 'ATOMIC_VAR_INIT' has been marked as deprecated}} \
1414
// expected-note@stdatomic.h:* {{macro marked 'deprecated' here}}
15-
#if defined(ATOMIC_FLAG_INIT) // cxx-warning {{macro 'ATOMIC_FLAG_INIT' has been marked as deprecated}} \
16-
// cxx-note@stdatomic.h:* {{macro marked 'deprecated' here}}
15+
#if defined(ATOMIC_FLAG_INIT) // Ok, deprecated in C++20, undeprecated in C++23 via LWG4659.
1716
#endif
1817
}

0 commit comments

Comments
 (0)