[libcxx] r332413 - Emit an error when include <atomic> after <stdatomic.h>

Volodymyr Sapsai via cfe-commits cfe-commits at lists.llvm.org
Tue May 15 15:38:31 PDT 2018


Author: vsapsai
Date: Tue May 15 15:38:31 2018
New Revision: 332413

URL: http://llvm.org/viewvc/llvm-project?rev=332413&view=rev
Log:
Emit an error when include <atomic> after <stdatomic.h>

C11 defines `kill_dependency` as a macro in <stdatomic.h>. When you
include <atomic> after <stdatomic.h>, the macro clashes with
`std::kill_dependency` and causes multiple errors. Explicit error should
help in diagnosing those errors.

No change for working code that includes <atomic> before <stdatomic.h>.

rdar://problem/27435938

Reviewers: rsmith, EricWF, mclow.lists, jfb

Reviewed By: jfb

Subscribers: jfb, jkorous-apple, christof, bumblebritches57, JonChesterfield, smeenai, cfe-commits

Differential Revision: https://reviews.llvm.org/D45470


Modified:
    libcxx/trunk/include/atomic

Modified: libcxx/trunk/include/atomic
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?rev=332413&r1=332412&r2=332413&view=diff
==============================================================================
--- libcxx/trunk/include/atomic (original)
+++ libcxx/trunk/include/atomic Tue May 15 15:38:31 2018
@@ -555,6 +555,9 @@ void atomic_signal_fence(memory_order m)
 #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
 #error <atomic> is not implemented
 #endif
+#ifdef kill_dependency
+#error C++ standard library is incompatible with <stdatomic.h>
+#endif
 
 #if _LIBCPP_STD_VER > 14
 # define __cpp_lib_atomic_is_always_lock_free 201603L




More information about the cfe-commits mailing list