Author: Saleem Abdulrasool Date: 2022-12-15T21:50:28Z New Revision: e0c3142af075e2ef89395dbed5939071345eb622
URL: https://github.com/llvm/llvm-project/commit/e0c3142af075e2ef89395dbed5939071345eb622 DIFF: https://github.com/llvm/llvm-project/commit/e0c3142af075e2ef89395dbed5939071345eb622.diff LOG: Headers: tweak inclusion condition for stdatomic.h MSVC requires that C++23 be available (_HAS_CXX23) else the entire content is elided. Conditionalise the inclusion properly so that C/C++ code using stdatomic.h for memory_order_* constants are able to do so without changing the C++ standard. This repairs builds of Swift and libdispatch after ba49d39b20cc5358da28af2ac82bd336028780bc. Differential Revision: https://reviews.llvm.org/D139266 Reviewed By: aaron.ballman, Mordante, fsb4000 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Headers/stdatomic.h Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 0da79fc1a2a9a..d9b44b629220d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -199,6 +199,8 @@ Major New Features Bug Fixes --------- +- ``stdatomic.h`` will use the internal declarations when targeting pre-C++-23 + on Windows platforms as the MSVC support requires newer C++ standard. - Correct ``_Static_assert`` to accept the same set of extended integer constant expressions as is accpted in other contexts that accept them. This fixes `Issue 57687 <https://github.com/llvm/llvm-project/issues/57687>`_. diff --git a/clang/lib/Headers/stdatomic.h b/clang/lib/Headers/stdatomic.h index 648af44f2a641..9093851b76cfc 100644 --- a/clang/lib/Headers/stdatomic.h +++ b/clang/lib/Headers/stdatomic.h @@ -15,10 +15,12 @@ * * Exclude the MSVC path as well as the MSVC header as of the 14.31.30818 * explicitly disallows `stdatomic.h` in the C mode via an `#error`. Fallback - * to the clang resource header until that is fully supported. + * to the clang resource header until that is fully supported. The + * `stdatomic.h` header requires C++ 23 or newer. */ #if __STDC_HOSTED__ && \ - __has_include_next(<stdatomic.h>) && !(defined(_MSC_VER) && !defined(__cplusplus)) + __has_include_next(<stdatomic.h>) && \ + !(defined(_MSC_VER) && defined(__cplusplus) && __cplusplus < 202002L) # include_next <stdatomic.h> #else _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits