Index: lib/Headers/stdatomic.h =================================================================== --- lib/Headers/stdatomic.h +++ lib/Headers/stdatomic.h @@ -31,6 +31,10 @@ # include_next #else +#if !defined(__ALLOW_STDC_ATOMICS_IN_CXX__) && defined(__cplusplus) +#error " is incompatible with the C++ standard library; define __ALLOW_STDC_ATOMICS_IN_CXX__ to proceed." +#endif + #include #include Index: test/Headers/stdatomic.cpp =================================================================== --- test/Headers/stdatomic.cpp +++ test/Headers/stdatomic.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify +// RUN: %clang_cc1 -D__ALLOW_STDC_ATOMICS_IN_CXX__ %s -verify + +#include + +#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__ +// expected-error@stdatomic.h:* {{ is incompatible with the C++ standard library}} +#else +// expected-no-diagnostics +#endif