[libcxx] r210195 - Make meta.trans.other/aligned_storage.pass.cpp pass on arm.

Nico Weber nicolasweber at gmx.de
Wed Jun 4 09:25:59 PDT 2014


Author: nico
Date: Wed Jun  4 11:25:58 2014
New Revision: 210195

URL: http://llvm.org/viewvc/llvm-project?rev=210195&view=rev
Log:
Make meta.trans.other/aligned_storage.pass.cpp pass on arm.

The maximum alignment on arm is 8, not 16 like on x86. Use alignof(max_align_t)
to make the test work in both cases.

Modified:
    libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp

Modified: libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp?rev=210195&r1=210194&r2=210195&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp Wed Jun  4 11:25:58 2014
@@ -159,12 +159,19 @@ int main()
     static_assert(std::alignment_of<T1>::value == 8, "");
     static_assert(sizeof(T1) == 16, "");
     }
+    // Use alignof(std::max_align_t) below to find the max alignment instead of
+    // hardcoding it, because it's different on different platforms.
+    // (For example 8 on arm and 16 on x86.)
+#if __cplusplus < 201103L
+#define alignof __alignof__
+#endif
     {
     typedef std::aligned_storage<16>::type T1;
 #if _LIBCPP_STD_VER > 11
     static_assert(std::is_same<std::aligned_storage_t<16>, T1>::value, "" );
 #endif
-    static_assert(std::alignment_of<T1>::value == 16, "");
+    static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
+                  "");
     static_assert(sizeof(T1) == 16, "");
     }
     {
@@ -172,8 +179,9 @@ int main()
 #if _LIBCPP_STD_VER > 11
     static_assert(std::is_same<std::aligned_storage_t<17>, T1>::value, "" );
 #endif
-    static_assert(std::alignment_of<T1>::value == 16, "");
-    static_assert(sizeof(T1) == 32, "");
+    static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
+                  "");
+    static_assert(sizeof(T1) == 16 + alignof(std::max_align_t), "");
     }
     {
     typedef std::aligned_storage<10>::type T1;





More information about the cfe-commits mailing list