[PATCH] Headers: Provide an ABI compatible max_align_t when _MSC_VER is defined
David Majnemer
david.majnemer at gmail.com
Mon Mar 3 01:44:58 PST 2014
Hi chandlerc, rsmith, rnk,
Our usual definition of max_align_t wouldn't match up with MSVC if it
was used in a template argument.
http://llvm-reviews.chandlerc.com/D2924
Files:
lib/Headers/stddef.h
test/Headers/c11.c
Index: lib/Headers/stddef.h
===================================================================
--- lib/Headers/stddef.h
+++ lib/Headers/stddef.h
@@ -85,12 +85,16 @@
#endif
#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
+#ifndef _MSC_VER
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;
+#else
+typedef double max_align_t;
+#endif
#define __CLANG_MAX_ALIGN_T_DEFINED
#endif
Index: test/Headers/c11.c
===================================================================
--- test/Headers/c11.c
+++ test/Headers/c11.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -fmodules %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 -fmsc-version=1700 %s
noreturn int f(); // expected-error 1+{{}}
@@ -27,6 +28,10 @@
_Static_assert(sizeof(max_align_t) >= sizeof(long double), "");
_Static_assert(alignof(max_align_t) >= alignof(long double), "");
+#ifdef _MSC_VER
+_Static_assert(sizeof(max_align_t) == sizeof(double), "");
+#endif
+
// 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).
#ifndef __STDC_HOSTED__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2924.1.patch
Type: text/x-patch
Size: 1485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140303/829cbf3f/attachment.bin>
More information about the cfe-commits
mailing list