[libc++] Add test and remove workaround for PR13592
authorLouis Dionne <ldionne@apple.com>
Wed, 30 Oct 2019 22:49:04 +0000 (15:49 -0700)
committerLouis Dionne <ldionne@apple.com>
Wed, 30 Oct 2019 22:52:11 +0000 (15:52 -0700)
PR13592 was caused by a problem in how to compiler implemented the
__is_convertible_to intrinsic. That problem, reported as PR13591,
was fixed back in 2012. We don't support such old versions of Clang
anyway, so we don't need the library workaround that had been added
to solve PR13592 (while waiting for the compiler fix).

libcxx/include/type_traits
libcxx/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp

index aa1fab3..54aa93f 100644 (file)
@@ -1418,8 +1418,7 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v
 #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
 
 template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible
-    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
-                                     !is_abstract<_T2>::value> {};
+    : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {};
 
 #else  // __has_feature(is_convertible_to)
 
index f299c5f..804650f 100644 (file)
@@ -60,6 +60,8 @@ class CannotInstantiate {
   enum { X = T::ThisExpressionWillBlowUp };
 };
 
+struct abstract { virtual int f() = 0; };
+
 int main(int, char**)
 {
     // void
@@ -244,8 +246,9 @@ int main(int, char**)
     static_assert((std::is_convertible<volatile NonCopyable&, const volatile NonCopyable&>::value), "");
     static_assert((std::is_convertible<const volatile NonCopyable&, const volatile NonCopyable&>::value), "");
     static_assert((!std::is_convertible<const NonCopyable&, NonCopyable&>::value), "");
-// This test requires Access control SFINAE which we only have in C++11 or when
-// we are using the compiler builtin for is_convertible.
+
+    // This test requires Access control SFINAE which we only have in C++11 or when
+    // we are using the compiler builtin for is_convertible.
     test_is_not_convertible<NonCopyable&, NonCopyable>();
 
 
@@ -253,5 +256,8 @@ int main(int, char**)
     // For example CannotInstantiate is instantiated as a part of ADL lookup for arguments of type CannotInstantiate*.
     static_assert((std::is_convertible<CannotInstantiate<int>*, CannotInstantiate<int>*>::value), "");
 
-  return 0;
+    // Test for PR13592
+    static_assert(!std::is_convertible<abstract, abstract>::value, "");
+
+    return 0;
 }