C17 deprecated ATOMIC_VAR_INIT with the resolution of DR 485. C++ followed suit when adopting P0883R2 for C++20, but additionally chose to deprecate ATOMIC_FLAG_INIT at the same time despite the macro still being required in C. This patch marks both macros as deprecated when appropriate to do so.
It does so by using #pragma clang deprecated and this patch presumes we don't have to guard those uses of the pragma with compiler or compiler version checks.
I believe libc++ will need some changes to address the deprecation as it seems it is using these macros. I'm not a libc++ maintainer and so I've added a few libc++ folks to the review so they can weigh in on whether libc++ should change first or can react to the changes in this patch. If libc++ needs to change first and you'd like me to drive those changes, I'd appreciate knowing what changes the maintainers would like to see there (I believe that removing the ATOMIC_VAR_INIT and using direct initialization would be appropriate, but I have no idea if the maintainers agree).
Hmm, I do think there ought to be some way for the C++20 programmer to suppress the deprecation warning for these macros (specifically, not just via -Wno-deprecated in their whole project). For deprecations in the C++ standard library, libc++ offers an all-or-nothing flag: basically you'd do
(This also makes it easy for libcxx/test/ to suppress the deprecation warning for the purposes of testing.)
However, I'm not sure if it's appropriate to mention _LIBCPP_DISABLE_DEPRECATION_WARNINGS in this header located in clang/lib/Headers/ instead of libcxx/include/. Someone else will have to make that call.
It might be that the only way for the programmer (or libcxx/test/) to work around the warning will be for them to pass -Wno-deprecated globally; IMO that is suboptimal but quite far from disastrous.