EricWF created this revision.
EricWF added reviewers: rsmith, jyknight.

GCC also considers the `__float128` type when constructing `max_align_t`. 
Clang's definition is intended to exactly match GCC's, so this patch make Clang 
do the same.

NOTE: This breaks the ABI of `max_align_t` by changing its size and alignment 
on 32 bit linux platforms.


Repository:
  rC Clang

https://reviews.llvm.org/D55057

Files:
  lib/Headers/__stddef_max_align_t.h
  test/Headers/c11.c


Index: test/Headers/c11.c
===================================================================
--- test/Headers/c11.c
+++ test/Headers/c11.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -fmodules 
-fmodules-cache-path=%t %s -D__STDC_WANT_LIB_EXT1__=1
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 
-fms-compatibility-version=17.00 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple 
i386-unknown-linux-gnu %s
 
 noreturn int f(); // expected-error 1+{{}}
 
@@ -29,8 +30,17 @@
 _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), "");
+_Static_assert(alignof(max_align_t) == alignof(double), "");
+#elif defined(__APPLE__)
+_Static_assert(sizeof(max_align_t) == sizeof(long double), "");
+_Static_assert(alignof(max_align_t) == alignof(long double), "");
+#else
+// Test compatibility with GCC's version
+_Static_assert(sizeof(max_align_t) >= sizeof(__float128), "");
+_Static_assert(alignof(max_align_t) >= alignof(__float128), "");
 #endif
 
 // If we are freestanding, then also check RSIZE_MAX (in a hosted 
implementation
Index: lib/Headers/__stddef_max_align_t.h
===================================================================
--- lib/Headers/__stddef_max_align_t.h
+++ lib/Headers/__stddef_max_align_t.h
@@ -37,6 +37,10 @@
       __attribute__((__aligned__(__alignof__(long long))));
   long double __clang_max_align_nonce2
       __attribute__((__aligned__(__alignof__(long double))));
+#ifdef __i386__
+  __float128 __clang_max_align_nonce3
+    __attribute__((__aligned__(__alignof__(__float128))));
+#endif
 } max_align_t;
 #endif
 


Index: test/Headers/c11.c
===================================================================
--- test/Headers/c11.c
+++ test/Headers/c11.c
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -fmodules -fmodules-cache-path=%t %s -D__STDC_WANT_LIB_EXT1__=1
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 -fms-compatibility-version=17.00 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i386-unknown-linux-gnu %s
 
 noreturn int f(); // expected-error 1+{{}}
 
@@ -29,8 +30,17 @@
 _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), "");
+_Static_assert(alignof(max_align_t) == alignof(double), "");
+#elif defined(__APPLE__)
+_Static_assert(sizeof(max_align_t) == sizeof(long double), "");
+_Static_assert(alignof(max_align_t) == alignof(long double), "");
+#else
+// Test compatibility with GCC's version
+_Static_assert(sizeof(max_align_t) >= sizeof(__float128), "");
+_Static_assert(alignof(max_align_t) >= alignof(__float128), "");
 #endif
 
 // If we are freestanding, then also check RSIZE_MAX (in a hosted implementation
Index: lib/Headers/__stddef_max_align_t.h
===================================================================
--- lib/Headers/__stddef_max_align_t.h
+++ lib/Headers/__stddef_max_align_t.h
@@ -37,6 +37,10 @@
       __attribute__((__aligned__(__alignof__(long long))));
   long double __clang_max_align_nonce2
       __attribute__((__aligned__(__alignof__(long double))));
+#ifdef __i386__
+  __float128 __clang_max_align_nonce3
+    __attribute__((__aligned__(__alignof__(__float128))));
+#endif
 } max_align_t;
 #endif
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to