fsb4000 created this revision. fsb4000 added a project: clang. Herald added a project: All. fsb4000 requested review of this revision. Herald added a subscriber: cfe-commits.
and use fallback only for C. It fixes the isssue with clang-cl: #include <stdatomic.h> #include <stdbool.h> #ifdef __cplusplus #include <atomic> using namespace std; #endif int main() { atomic_bool b = true; } $ clang-cl /TC main.cpp # works $ clang-cl /TP /std:c++20 main.cpp stdatomic.h(70,6): error: conflicting types for 'atomic_thread_fence' void atomic_thread_fence(memory_order); ^ atomic(166,24): note: previous definition is here extern "C" inline void atomic_thread_fence(const memory_order _Order) noexcept { ... fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. Many errors but `<stdatomic.h>` has many macros to built-in functions. #define atomic_thread_fence(order) __c11_atomic_thread_fence(order) and MSVC `<atomic>` has real functions. and the built-in functions are redefined. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D130419 Files: clang/lib/Headers/stdatomic.h Index: clang/lib/Headers/stdatomic.h =================================================================== --- clang/lib/Headers/stdatomic.h +++ clang/lib/Headers/stdatomic.h @@ -17,7 +17,8 @@ * explicitly disallows `stdatomic.h` in the C mode via an `#error`. Fallback * to the clang resource header until that is fully supported. */ -#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>) && !defined(_MSC_VER) +#if __STDC_HOSTED__ && \ + __has_include_next(<stdatomic.h>) && !(defined(_MSC_VER) && !defined(__cplusplus)) # include_next <stdatomic.h> #else
Index: clang/lib/Headers/stdatomic.h =================================================================== --- clang/lib/Headers/stdatomic.h +++ clang/lib/Headers/stdatomic.h @@ -17,7 +17,8 @@ * explicitly disallows `stdatomic.h` in the C mode via an `#error`. Fallback * to the clang resource header until that is fully supported. */ -#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>) && !defined(_MSC_VER) +#if __STDC_HOSTED__ && \ + __has_include_next(<stdatomic.h>) && !(defined(_MSC_VER) && !defined(__cplusplus)) # include_next <stdatomic.h> #else
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits