[PATCH] D29140: [libcxx] [test] Avoid MSVC's non-Standard ABI in underlying_type.pass.cpp.

Stephan T. Lavavej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 10:40:01 PST 2017


STL_MSFT created this revision.

[libcxx] [test] Avoid MSVC's non-Standard ABI in underlying_type.pass.cpp.

When compiled with Clang for Windows, this was emitting "enumerator value
evaluates to 4294967295, which cannot be narrowed to type 'int' [-Wc++11-narrowing]".

The test should more strenuously avoid poking this ABI deficiency (and it
already has coverage for explicitly specified underlying types).


https://reviews.llvm.org/D29140

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


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
@@ -17,32 +17,40 @@
 #include "test_macros.h"
 
 enum E { V = INT_MIN };
-enum F { W = UINT_MAX };
 
-int main()
-{
 #if !defined(_WIN32) || defined(__MINGW32__)
-    typedef unsigned ExpectUnsigned;
+    #define TEST_UNSIGNED_UNDERLYING_TYPE 1
 #else
-    typedef int ExpectUnsigned; // MSVC's ABI doesn't follow the Standard
+    #define TEST_UNSIGNED_UNDERLYING_TYPE 0 // MSVC's ABI doesn't follow the Standard
 #endif
+
+#if TEST_UNSIGNED_UNDERLYING_TYPE
+enum F { W = UINT_MAX };
+#endif // TEST_UNSIGNED_UNDERLYING_TYPE
+
+int main()
+{
     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, ExpectUnsigned>::value),
+#if TEST_UNSIGNED_UNDERLYING_TYPE
+    static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value),
                   "F has the wrong underlying type");
+#endif // TEST_UNSIGNED_UNDERLYING_TYPE
 
 #if TEST_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>, ExpectUnsigned>::value), "");
-#endif
+#if TEST_UNSIGNED_UNDERLYING_TYPE
+    static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), "");
+#endif // TEST_UNSIGNED_UNDERLYING_TYPE
+#endif // TEST_STD_VER > 11
 
 #if TEST_STD_VER >= 11
     enum G : char { };
 
     static_assert((std::is_same<std::underlying_type<G>::type, char>::value),
                   "G has the wrong underlying type");
 #if TEST_STD_VER > 11
     static_assert((std::is_same<std::underlying_type_t<G>, char>::value), "");
-#endif
+#endif // TEST_STD_VER > 11
 #endif // TEST_STD_VER >= 11
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29140.85782.patch
Type: text/x-patch
Size: 2043 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170125/aba36770/attachment-0001.bin>


More information about the cfe-commits mailing list