[libcxx-commits] [PATCH] D61655: [libcxx] teach type_traits test about long uint32_t

Brian Cain via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 7 13:56:28 PDT 2019


bcain created this revision.
bcain added reviewers: mclow.lists, EricWF, bcraig.
bcain added a project: libc++.
Herald added subscribers: libcxx-commits, christof.

Patch by Ben Craig.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61655

Files:
  libcxx/test/libcxx/type_traits/convert_to_integral.pass.cpp


Index: libcxx/test/libcxx/type_traits/convert_to_integral.pass.cpp
===================================================================
--- libcxx/test/libcxx/type_traits/convert_to_integral.pass.cpp
+++ libcxx/test/libcxx/type_traits/convert_to_integral.pass.cpp
@@ -87,7 +87,14 @@
   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>();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61655.198525.patch
Type: text/x-patch
Size: 1176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190507/ec68148e/attachment.bin>


More information about the libcxx-commits mailing list