[PATCH] D22017: [libcxx] [test] Work around MSVC's non-Standard ABI for enums.

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 5 13:57:43 PDT 2016


STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Work around MSVC's non-Standard ABI for enums.

So this is definitely an MSVC bug, but one that's baked into our layout behavior, so even Clang has to enable it unconditionally when targeting Windows.

In underlying_type.pass.cpp, I'm simply marking the affected static_asserts as libcxx-specific (this probably won't be sufficient when you try to get the Clang/LLVM/libcxx stack running on Windows). In make_signed.pass.cpp and make_unsigned.pass.cpp, I'm giving the enum an explicitly specified underlying type, so the tests below can remain unaffected.

If there's a better way to do this, please let me know. I could give underlying_type.pass.cpp an explicitly specified underlying type, but I'm unsure as to how your C++03 tests work.

http://reviews.llvm.org/D22017

Files:
  test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
  test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
  test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp

Index: test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
===================================================================
--- test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
@@ -13,9 +13,15 @@
 
 #include <type_traits>
 
+#include "test_macros.h"
+
 enum Enum {zero, one_};
 
+#if TEST_STD_VER >= 11
+enum BigEnum : unsigned long long // MSVC's ABI doesn't follow the Standard
+#else
 enum BigEnum
+#endif
 {
     bigzero,
     big = 0xFFFFFFFFFFFFFFFFULL
Index: test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
===================================================================
--- test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
@@ -13,9 +13,15 @@
 
 #include <type_traits>
 
+#include "test_macros.h"
+
 enum Enum {zero, one_};
 
+#if TEST_STD_VER >= 11
+enum BigEnum : unsigned long long // MSVC's ABI doesn't follow the Standard
+#else
 enum BigEnum
+#endif
 {
     bigzero,
     big = 0xFFFFFFFFFFFFFFFFULL
Index: test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
===================================================================
--- test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
+++ test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
@@ -23,12 +23,12 @@
 {
     static_assert((std::is_same<std::underlying_type<E>::type, int>::value),
                   "E has the wrong underlying type");
-    static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value),
-                  "F has the wrong underlying type");
+    LIBCPP_STATIC_ASSERT((std::is_same<std::underlying_type<F>::type, unsigned>::value),
+                  "F has the wrong underlying type"); // MSVC's ABI doesn't follow the Standard
 
 #if _LIBCPP_STD_VER > 11
     static_assert((std::is_same<std::underlying_type_t<E>, int>::value), "");
-    static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), "");
+    LIBCPP_STATIC_ASSERT((std::is_same<std::underlying_type_t<F>, unsigned>::value), ""); // MSVC's ABI
 #endif
 
 #if TEST_STD_VER >= 11


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22017.62788.patch
Type: text/x-patch
Size: 2293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160705/e2571cb5/attachment.bin>


More information about the cfe-commits mailing list