diff options
author | Volodymyr Sapsai <vsapsai@apple.com> | 2018-05-02 17:56:45 +0000 |
---|---|---|
committer | Volodymyr Sapsai <vsapsai@apple.com> | 2018-05-02 17:56:45 +0000 |
commit | 8fc472d96acf25b63d3faf3bd5101e654de04b42 (patch) | |
tree | c14e3beb2e2f27ae5210c5db81bc2831eedcb4db /test | |
parent | b110f380824101d375673db968dca84ac484164a (diff) | |
download | external_libcxx-8fc472d96acf25b63d3faf3bd5101e654de04b42.tar.gz external_libcxx-8fc472d96acf25b63d3faf3bd5101e654de04b42.tar.bz2 external_libcxx-8fc472d96acf25b63d3faf3bd5101e654de04b42.zip |
Emit an error when mixing <stdatomic.h> and <atomic>
Atomics in C and C++ are incompatible at the moment and mixing the
headers can result in confusing error messages.
Emit an error explicitly telling about the incompatibility. Introduce
the macro `__ALLOW_STDC_ATOMICS_IN_CXX__` that allows to choose in C++
between C atomics and C++ atomics.
rdar://problem/27435938
Reviewers: rsmith, EricWF, mclow.lists
Reviewed By: mclow.lists
Subscribers: jkorous-apple, christof, bumblebritches57, JonChesterfield, smeenai, cfe-commits
Differential Revision: https://reviews.llvm.org/D45470
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@331379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/libcxx/atomics/c_compatibility.fail.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/libcxx/atomics/c_compatibility.fail.cpp b/test/libcxx/atomics/c_compatibility.fail.cpp new file mode 100644 index 000000000..092687d5b --- /dev/null +++ b/test/libcxx/atomics/c_compatibility.fail.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// +// <atomic> + +// Test that including <atomic> fails to compile when we want to use C atomics +// in C++ and have corresponding macro defined. + +// MODULES_DEFINES: __ALLOW_STDC_ATOMICS_IN_CXX__ +#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__ +#define __ALLOW_STDC_ATOMICS_IN_CXX__ +#endif + +#include <atomic> +// expected-error@atomic:* {{<stdatomic.h> is incompatible with the C++ standard library}} + +int main() +{ +} + |