diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-21 02:17:58 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-02-21 02:17:58 +0000 |
| commit | 8acb4044d83ecc9df81b1c9f327d5bd4325e1756 (patch) | |
| tree | 40476640dc8e8148b20ab228018a262594fd1f3e | |
| parent | dc46338e2d9c534a53369901fc8025fab9cbc9ba (diff) | |
| download | bcm5719-llvm-8acb4044d83ecc9df81b1c9f327d5bd4325e1756.tar.gz bcm5719-llvm-8acb4044d83ecc9df81b1c9f327d5bd4325e1756.zip | |
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.
llvm-svn: 175708
| -rw-r--r-- | clang/lib/Headers/stdalign.h | 3 | ||||
| -rw-r--r-- | clang/test/Headers/cxx11.cpp | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Headers/stdalign.h b/clang/lib/Headers/stdalign.h index 97b18f175b9..3738d1284f9 100644 --- a/clang/lib/Headers/stdalign.h +++ b/clang/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/clang/test/Headers/cxx11.cpp b/clang/test/Headers/cxx11.cpp new file mode 100644 index 00000000000..995fc6528de --- /dev/null +++ b/clang/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, ""); |

