[PATCH] D45470: Emit an error when mixing <stdatomic.h> and <atomic>

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 2 10:55:29 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC331378: Emit an error when mixing <stdatomic.h> and <atomic> (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45470?vs=143817&id=144903#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45470

Files:
  lib/Headers/stdatomic.h
  test/Headers/stdatomic.cpp


Index: lib/Headers/stdatomic.h
===================================================================
--- lib/Headers/stdatomic.h
+++ lib/Headers/stdatomic.h
@@ -31,6 +31,10 @@
 # include_next <stdatomic.h>
 #else
 
+#if !defined(__ALLOW_STDC_ATOMICS_IN_CXX__) && defined(__cplusplus)
+#error "<stdatomic.h> is incompatible with the C++ standard library; define __ALLOW_STDC_ATOMICS_IN_CXX__ to proceed."
+#endif
+
 #include <stddef.h>
 #include <stdint.h>
 
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 <stdatomic.h>
+
+#ifndef __ALLOW_STDC_ATOMICS_IN_CXX__
+// expected-error at stdatomic.h:* {{<stdatomic.h> is incompatible with the C++ standard library}}
+#else
+// expected-no-diagnostics
+#endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45470.144903.patch
Type: text/x-patch
Size: 938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180502/f733a2e8/attachment.bin>


More information about the cfe-commits mailing list