[clang] 3cfa32a - Undeprecate ATOMIC_FLAG_INIT in C++
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 12 03:50:38 PDT 2022
Author: Aaron Ballman
Date: 2022-07-12T06:48:31-04:00
New Revision: 3cfa32a71ecfbc1bf993358e32b916cf3483299f
URL: https://github.com/llvm/llvm-project/commit/3cfa32a71ecfbc1bf993358e32b916cf3483299f
DIFF: https://github.com/llvm/llvm-project/commit/3cfa32a71ecfbc1bf993358e32b916cf3483299f.diff
LOG: 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
1544d1f9fdb115782202d72ad200c3f93b2c4f5a.
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Headers/stdatomic.h
clang/test/Headers/stdatomic-deprecations.c
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 86b9b7ef471bb..ce76de44e2f0f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -486,6 +486,7 @@ C++2b Feature Support
- Implemented `P2128R6: Multidimensional subscript operator <https://wg21.link/P2128R6>`_.
- Implemented `P0849R8: auto(x): decay-copy in the language <https://wg21.link/P0849R8>`_.
- Implemented `P2242R3: Non-literal variables (and labels and gotos) in constexpr functions <https://wg21.link/P2242R3>`_.
+- Implemented `LWG3659: Consider ATOMIC_FLAG_INIT undeprecation <https://wg21.link/LWG3659>`_.
CUDA/HIP Language Changes in Clang
----------------------------------
diff --git a/clang/lib/Headers/stdatomic.h b/clang/lib/Headers/stdatomic.h
index 780bcc2dfea17..3a0b9cc056bef 100644
--- a/clang/lib/Headers/stdatomic.h
+++ b/clang/lib/Headers/stdatomic.h
@@ -158,10 +158,6 @@ typedef _Atomic(uintmax_t) atomic_uintmax_t;
typedef struct atomic_flag { atomic_bool _Value; } atomic_flag;
#define ATOMIC_FLAG_INIT { 0 }
-#if __cplusplus >= 202002L && !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
-/* ATOMIC_FLAG_INIT was deprecated in C++20 but is not deprecated in C. */
-#pragma clang deprecated(ATOMIC_FLAG_INIT)
-#endif
/* These should be provided by the libc implementation. */
#ifdef __cplusplus
diff --git a/clang/test/Headers/stdatomic-deprecations.c b/clang/test/Headers/stdatomic-deprecations.c
index 56ee33e16f51a..b850f7cb4c3f3 100644
--- a/clang/test/Headers/stdatomic-deprecations.c
+++ b/clang/test/Headers/stdatomic-deprecations.c
@@ -12,7 +12,6 @@
void func(void) {
_Atomic int i = ATOMIC_VAR_INIT(12); // expected-warning {{macro 'ATOMIC_VAR_INIT' has been marked as deprecated}} \
// expected-note at stdatomic.h:* {{macro marked 'deprecated' here}}
- #if defined(ATOMIC_FLAG_INIT) // cxx-warning {{macro 'ATOMIC_FLAG_INIT' has been marked as deprecated}} \
- // cxx-note at stdatomic.h:* {{macro marked 'deprecated' here}}
+ #if defined(ATOMIC_FLAG_INIT) // Ok, deprecated in C++20, undeprecated in C++23 via LWG4659.
#endif
}
More information about the cfe-commits
mailing list