[libc++] Fix std::is_array<T[0]> and add tests

Differential Revision: https://reviews.llvm.org/D122810
This commit is contained in:
Louis Dionne 2022-03-31 09:25:31 -04:00
parent 5d90004874
commit 13796495ec
4 changed files with 10 additions and 11 deletions

View File

@ -758,7 +758,9 @@ inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value;
// is_array // 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> template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { }; struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { };

View File

@ -73,6 +73,7 @@ typedef void (*FunctionPtr)();
int main(int, char**) int main(int, char**)
{ {
test_is_array<char[3]>(); test_is_array<char[3]>();
test_is_not_array<char[0]>();
test_is_array<char[]>(); test_is_array<char[]>();
test_is_array<Union[]>(); test_is_array<Union[]>();

View File

@ -32,9 +32,6 @@ void test_array()
test_array_imp<const volatile T, B>(); test_array_imp<const volatile T, B>();
} }
typedef char array[3];
typedef char incomplete_array[];
class incomplete_type; class incomplete_type;
class Empty {}; class Empty {};
@ -65,8 +62,9 @@ int main(int, char**)
test_array<FunctionPtr, false>(); test_array<FunctionPtr, false>();
// Array types // Array types
test_array<array, true>(); test_array<char[3], true>();
test_array<incomplete_array, false>(); test_array<int[0], false>();
test_array<char[], false>();
test_array<incomplete_type[], false>(); test_array<incomplete_type[], false>();
return 0; return 0;

View File

@ -32,9 +32,6 @@ void test_array()
test_array_imp<const volatile T, B>(); test_array_imp<const volatile T, B>();
} }
typedef char array[3];
typedef char incomplete_array[];
class incomplete_type; class incomplete_type;
class Empty {}; class Empty {};
@ -65,8 +62,9 @@ int main(int, char**)
test_array<FunctionPtr, false>(); test_array<FunctionPtr, false>();
// Array types // Array types
test_array<array, false>(); test_array<char[3], false>();
test_array<incomplete_array, true>(); test_array<int[0], false>();
test_array<char[], true>();
test_array<incomplete_type[], true>(); test_array<incomplete_type[], true>();
return 0; return 0;