From b40cb9832b4b41bc459641ca940b946c5211f091 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sun, 5 Feb 2017 22:48:13 +0000 Subject: [PATCH] [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). Fixes D29140. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294159 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../meta.trans.other/underlying_type.pass.cpp | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp index 410e47e03..b00798b72 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp @@ -17,24 +17,32 @@ #include "test_macros.h" enum E { V = INT_MIN }; + +#if !defined(_WIN32) || defined(__MINGW32__) + #define TEST_UNSIGNED_UNDERLYING_TYPE 1 +#else + #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() { -#if !defined(_WIN32) || defined(__MINGW32__) - typedef unsigned ExpectUnsigned; -#else - typedef int ExpectUnsigned; // MSVC's ABI doesn't follow the Standard -#endif static_assert((std::is_same::type, int>::value), "E has the wrong underlying type"); - static_assert((std::is_same::type, ExpectUnsigned>::value), +#if TEST_UNSIGNED_UNDERLYING_TYPE + static_assert((std::is_same::type, unsigned>::value), "F has the wrong underlying type"); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE #if TEST_STD_VER > 11 static_assert((std::is_same, int>::value), ""); - static_assert((std::is_same, ExpectUnsigned>::value), ""); -#endif +#if TEST_UNSIGNED_UNDERLYING_TYPE + static_assert((std::is_same, unsigned>::value), ""); +#endif // TEST_UNSIGNED_UNDERLYING_TYPE +#endif // TEST_STD_VER > 11 #if TEST_STD_VER >= 11 enum G : char { }; @@ -43,6 +51,6 @@ int main() "G has the wrong underlying type"); #if TEST_STD_VER > 11 static_assert((std::is_same, char>::value), ""); -#endif +#endif // TEST_STD_VER > 11 #endif // TEST_STD_VER >= 11 }