Headers: further refine the `stdatomic.h` MSVC inclusion
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 21 Dec 2022 16:45:28 +0000 (16:45 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 21 Dec 2022 19:09:10 +0000 (19:09 +0000)
The `stdatomic.h` header cannot be included under MSVC when in C++ mode
as the toolsets prior to 17.5.0 Preview 2 do not support the C11
atomics.  However, some toolsets prior to the aforementioned version
support the atomics under the C++ mode.  In these versions the MSVC
toolset protects against the contamination by entirely eliding the
declarations, resulting in build failures in some cases.  Unfortunately,
e0c3142af075e2ef89395dbed5939071345eb622 accidentally regressed the C
case when fixing the C++ support.

Unfortunately, we cannot test this reliably as we need to inject a
header after the resource path as a system header path, which we do not
have a reliable means of doing.

Fixes: #59640

clang/lib/Headers/stdatomic.h

index 9093851..0f893be 100644 (file)
@@ -20,7 +20,7 @@
  */
 #if __STDC_HOSTED__ &&                                                         \
     __has_include_next(<stdatomic.h>) &&                                       \
-    !(defined(_MSC_VER) && defined(__cplusplus) && __cplusplus < 202002L)
+    (!defined(_MSC_VER) || (defined(__cplusplus) && __cplusplus >= 202002L))
 # include_next <stdatomic.h>
 #else