[libcxx-commits] [libcxx] r360590 - [libcxx] teach type_traits test about long uint32_t

Brian Cain via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 13 08:41:18 PDT 2019


Author: bcain
Date: Mon May 13 08:41:18 2019
New Revision: 360590

URL: http://llvm.org/viewvc/llvm-project?rev=360590&view=rev
Log:
[libcxx] teach type_traits test about long uint32_t

Patch by Ben Craig.



Modified:
    libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp

Modified: libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp?rev=360590&r1=360589&r2=360590&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp Mon May 13 08:41:18 2019
@@ -87,7 +87,14 @@ int main(int, char**)
   check_integral_types<unsigned char, int>();
   check_integral_types<wchar_t, decltype(((wchar_t)1) + 1)>();
   check_integral_types<char16_t, int>();
-  check_integral_types<char32_t, uint32_t>();
+  // On some platforms, unsigned int and long are the same size.  These
+  // platforms have a choice of making uint32_t an int or a long.  However
+  // char32_t must promote to an unsigned int on these platforms [conv.prom].
+  // Use the following logic to make the test work on such platforms.
+  // (sizeof(uint32_t) == sizeof(unsigned int)) ? unsigned int : uint32_t;
+  typedef std::conditional<sizeof(uint32_t) == sizeof(unsigned int),
+                           unsigned int, uint32_t>::type char_integral;
+  check_integral_types<char32_t, char_integral>();
   check_integral_types<short, int>();
   check_integral_types<unsigned short, int>();
   check_integral_types<int, int>();




More information about the libcxx-commits mailing list