[libcxx-commits] [PATCH] D122810: [libc++] Fix std::is_array<T[0]> and add tests

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 1 12:38:52 PDT 2022


ldionne updated this revision to Diff 419833.
ldionne retitled this revision from "[libc++] Test arrays with 0 size in our is_FOO_array tests" to "[libc++] Fix std::is_array<T[0]> and add tests".
ldionne added a comment.

Actually fix libc++'s implementation of std::is_array


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122810/new/

https://reviews.llvm.org/D122810

Files:
  libcxx/include/type_traits
  libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp
  libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_bounded_array.pass.cpp
  libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_unbounded_array.pass.cpp


Index: libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_unbounded_array.pass.cpp
===================================================================
--- libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_unbounded_array.pass.cpp
+++ libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_unbounded_array.pass.cpp
@@ -32,9 +32,6 @@
     test_array_imp<const volatile T, B>();
 }
 
-typedef char array[3];
-typedef char incomplete_array[];
-
 class incomplete_type;
 
 class Empty {};
@@ -65,8 +62,9 @@
     test_array<FunctionPtr,    false>();
 
 //  Array types
-    test_array<array,             false>();
-    test_array<incomplete_array,  true>();
+    test_array<char[3],           false>();
+    test_array<char[0],           false>();
+    test_array<char[],            true>();
     test_array<incomplete_type[], true>();
 
   return 0;
Index: libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_bounded_array.pass.cpp
===================================================================
--- libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_bounded_array.pass.cpp
+++ libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_bounded_array.pass.cpp
@@ -32,9 +32,6 @@
     test_array_imp<const volatile T, B>();
 }
 
-typedef char array[3];
-typedef char incomplete_array[];
-
 class incomplete_type;
 
 class Empty {};
@@ -65,8 +62,9 @@
     test_array<FunctionPtr,    false>();
 
 //  Array types
-    test_array<array,             true>();
-    test_array<incomplete_array,  false>();
+    test_array<char[3],           true>();
+    test_array<char[0],           false>();
+    test_array<char[],            false>();
     test_array<incomplete_type[], false>();
 
   return 0;
Index: libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp
===================================================================
--- libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp
+++ libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp
@@ -73,6 +73,7 @@
 int main(int, char**)
 {
     test_is_array<char[3]>();
+    test_is_not_array<char[0]>();
     test_is_array<char[]>();
     test_is_array<Union[]>();
 
Index: libcxx/include/type_traits
===================================================================
--- libcxx/include/type_traits
+++ libcxx/include/type_traits
@@ -758,7 +758,9 @@
 
 // is_array
 
-#if __has_keyword(__is_array)
+// TODO: Clang incorrectly reports that __is_array is true for T[0].
+//       Re-enable the branch once https://llvm.org/PR54705 is fixed.
+#if __has_keyword(__is_array) && 0
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122810.419833.patch
Type: text/x-patch
Size: 2729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220401/f0aadcc5/attachment.bin>


More information about the libcxx-commits mailing list