libstdc++'s <cstdalign> #includes <stdalign.h> and expects it to guard against
being included in C++. Don't define alignof or alignas in this case. Note that
the C++11 standard is broken in various ways here (it refers to the contents
of <stdalign.h> in C99, where that header did not exist, and doesn't mention
the alignas macro at all), but we do our best to do what it intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175708 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Headers/stdalign.h b/lib/Headers/stdalign.h
index 97b18f1..3738d12 100644
--- a/lib/Headers/stdalign.h
+++ b/lib/Headers/stdalign.h
@@ -24,8 +24,11 @@
 #ifndef __STDALIGN_H
 #define __STDALIGN_H
 
+#ifndef __cplusplus
 #define alignas _Alignas
 #define alignof _Alignof
+#endif
+
 #define __alignas_is_defined 1
 #define __alignof_is_defined 1
 
diff --git a/test/Headers/cxx11.cpp b/test/Headers/cxx11.cpp
new file mode 100644
index 0000000..995fc65
--- /dev/null
+++ b/test/Headers/cxx11.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang -fsyntax-only -std=c++11 %s
+
+#include <stdalign.h>
+
+#if defined alignas
+#error alignas should not be defined in C++
+#endif
+
+#if defined alignof
+#error alignof should not be defined in C++
+#endif
+
+static_assert(__alignas_is_defined, "");
+static_assert(__alignof_is_defined, "");