diff options
-rw-r--r-- | lib/Headers/stddef.h | 10 | ||||
-rw-r--r-- | test/Headers/c11.c | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Headers/stddef.h b/lib/Headers/stddef.h index 6a64d6d32a..b6926942ef 100644 --- a/lib/Headers/stddef.h +++ b/lib/Headers/stddef.h @@ -84,6 +84,16 @@ using ::std::nullptr_t; #endif #endif +#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L +typedef struct { + long long __clang_max_align_nonce1 + __attribute__((__aligned__(__alignof__(long long)))); + long double __clang_max_align_nonce2 + __attribute__((__aligned__(__alignof__(long double)))); +} max_align_t; +#define __CLANG_MAX_ALIGN_T_DEFINED +#endif + #define offsetof(t, d) __builtin_offsetof(t, d) #endif /* __STDDEF_H */ diff --git a/test/Headers/c11.c b/test/Headers/c11.c index 11bec19544..e335d0cebc 100644 --- a/test/Headers/c11.c +++ b/test/Headers/c11.c @@ -22,6 +22,10 @@ _Static_assert(__alignof(c) == 4, ""); #define __STDC_WANT_LIB_EXT1__ 1 #include <stddef.h> rsize_t x = 0; +_Static_assert(sizeof(max_align_t) >= sizeof(long long), ""); +_Static_assert(alignof(max_align_t) >= alignof(long long), ""); +_Static_assert(sizeof(max_align_t) >= sizeof(long double), ""); +_Static_assert(alignof(max_align_t) >= alignof(long double), ""); // If we are freestanding, then also check RSIZE_MAX (in a hosted implementation // we will use the host stdint.h, which may not yet have C11 support). |