[PATCH] D144196: [C2x] Remove the ATOMIC_VAR_INIT macro from stdatomic.h
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 24 10:54:33 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG898c673e0835: [C2x] Remove the ATOMIC_VAR_INIT macro from stdatomic.h (authored by aaron.ballman).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144196/new/
https://reviews.llvm.org/D144196
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Headers/stdatomic.h
clang/test/C/C2x/n2886.c
clang/www/c_status.html
Index: clang/www/c_status.html
===================================================================
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1131,7 +1131,7 @@
<tr>
<td>Remove ATOMIC_VAR_INIT v2</td>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm">N2886</a></td>
- <td class="none" align="center">No</td>
+ <td class="unreleased" align="center">Clang 17</td>
</tr>
<tr>
<td>Require exact-width integer type interfaces v2</td>
Index: clang/test/C/C2x/n2886.c
===================================================================
--- /dev/null
+++ clang/test/C/C2x/n2886.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=okay -std=c11 -ffreestanding %s
+// RUN: %clang_cc1 -verify -std=c17 -ffreestanding %s
+// RUN: %clang_cc1 -verify -std=c2x -ffreestanding %s
+
+/* WG14 N2886: yes
+ * Remove ATOMIC_VAR_INIT v2
+ */
+
+/* okay-no-diagnostics */
+#include <stdatomic.h>
+
+_Atomic int a = ATOMIC_VAR_INIT(0); /* #diag */
+#if __STDC_VERSION__ <= 201710L
+/* expected-warning@#diag {{macro 'ATOMIC_VAR_INIT' has been marked as deprecated}}
+ expected-note at stdatomic.h:* {{macro marked 'deprecated' here}}
+*/
+#else
+/* expected-error@#diag {{use of undeclared identifier 'ATOMIC_VAR_INIT'}} */
+#endif
+
Index: clang/lib/Headers/stdatomic.h
===================================================================
--- clang/lib/Headers/stdatomic.h
+++ clang/lib/Headers/stdatomic.h
@@ -45,9 +45,16 @@
#define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
/* 7.17.2 Initialization */
-
+/* FIXME: This is using the placeholder dates Clang produces for these macros
+ in C2x mode; switch to the correct values once they've been published. */
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202000L) || \
+ defined(__cplusplus)
+/* ATOMIC_VAR_INIT was removed in C2x, but still remains in C++2b. */
#define ATOMIC_VAR_INIT(value) (value)
-#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L) || \
+#endif
+
+#if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L && \
+ __STDC_VERSION__ < 202000L) || \
(defined(__cplusplus) && __cplusplus >= 202002L)) && \
!defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
/* ATOMIC_VAR_INIT was deprecated in C17 and C++20. */
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -94,6 +94,9 @@
- Implemented the ``unreachable`` macro in freestanding ``<stddef.h>`` for
`WG14 N2826 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2826.pdf>`_
+- Removed the ``ATOMIC_VAR_INIT`` macro in C2x and later standards modes, which
+ implements `WG14 N2886 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm>`_
+
Non-comprehensive list of changes in this release
-------------------------------------------------
- Clang now saves the address of ABI-indirect function parameters on the stack,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144196.500257.patch
Type: text/x-patch
Size: 3106 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230224/892f1a5c/attachment.bin>
More information about the cfe-commits
mailing list