[libcxx] r216909 - Fix PR#20834 - 'is_trivially_destructible yeilds wrong answer for arrays of unknown bound' Thanks to K-ballo for the bug report. Update a few of the other tests while we're here, and fix a typo in a test name.

Marshall Clow mclow.lists at gmail.com
Tue Sep 2 09:19:39 PDT 2014


Author: marshall
Date: Tue Sep  2 11:19:38 2014
New Revision: 216909

URL: http://llvm.org/viewvc/llvm-project?rev=216909&view=rev
Log:
Fix PR#20834 - 'is_trivially_destructible yeilds wrong answer for arrays of unknown bound' Thanks to K-ballo for the bug report. Update a few of the other tests while we're here, and fix a typo in a test name.

Added:
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp
      - copied unchanged from r216904, libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
Removed:
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
Modified:
    libcxx/trunk/include/type_traits
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
    libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Tue Sep  2 11:19:38 2014
@@ -2861,7 +2861,7 @@ template <class _Tp> struct _LIBCPP_TYPE
 #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
 
 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
-    : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
+    : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
 
 #else
 

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp Tue Sep  2 11:19:38 2014
@@ -69,7 +69,7 @@ int main()
     test_has_not_virtual_destructor<int*>();
     test_has_not_virtual_destructor<const int*>();
     test_has_not_virtual_destructor<char[3]>();
-    test_has_not_virtual_destructor<char[3]>();
+    test_has_not_virtual_destructor<char[]>();
     test_has_not_virtual_destructor<bit_zero>();
 
     test_has_virtual_destructor<Abstract>();

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp Tue Sep  2 11:19:38 2014
@@ -61,7 +61,7 @@ int main()
     test_is_not_abstract<int*>();
     test_is_not_abstract<const int*>();
     test_is_not_abstract<char[3]>();
-    test_is_not_abstract<char[3]>();
+    test_is_not_abstract<char[]>();
     test_is_not_abstract<Union>();
     test_is_not_abstract<Empty>();
     test_is_not_abstract<bit_zero>();

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp Tue Sep  2 11:19:38 2014
@@ -30,7 +30,7 @@ int main()
     test_is_const<int*>();
     test_is_const<const int*>();
     test_is_const<char[3]>();
-    test_is_const<char[3]>();
+    test_is_const<char[]>();
 
     static_assert(!std::is_const<int&>::value, "");
     static_assert(!std::is_const<const int&>::value, "");

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp Tue Sep  2 11:19:38 2014
@@ -56,7 +56,7 @@ int main()
     test_is_not_empty<int*>();
     test_is_not_empty<const int*>();
     test_is_not_empty<char[3]>();
-    test_is_not_empty<char[3]>();
+    test_is_not_empty<char[]>();
     test_is_not_empty<Union>();
     test_is_not_empty<NotEmpty>();
 

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp Tue Sep  2 11:19:38 2014
@@ -60,7 +60,6 @@ int main()
     test_is_not_move_assignable<const int> ();
     test_is_not_move_assignable<int[]> ();
     test_is_not_move_assignable<int[3]> ();
-    test_is_not_move_assignable<int[3]> ();
 #endif
     test_is_not_move_assignable<void> ();
 }

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp Tue Sep  2 11:19:38 2014
@@ -23,7 +23,7 @@ void test_is_nothrow_destructible()
 }
 
 template <class T>
-void test_has_not_nothrow_destructor()
+void test_is_not_nothrow_destructible()
 {
     static_assert(!std::is_nothrow_destructible<T>::value, "");
     static_assert(!std::is_nothrow_destructible<const T>::value, "");
@@ -64,9 +64,10 @@ struct A
 
 int main()
 {
-    test_has_not_nothrow_destructor<void>();
-    test_has_not_nothrow_destructor<AbstractDestructor>();
-    test_has_not_nothrow_destructor<NotEmpty>();
+    test_is_not_nothrow_destructible<void>();
+    test_is_not_nothrow_destructible<AbstractDestructor>();
+    test_is_not_nothrow_destructible<NotEmpty>();
+    test_is_not_nothrow_destructible<char[]>();
 
 #if __has_feature(cxx_noexcept)
     test_is_nothrow_destructible<A>();
@@ -83,7 +84,6 @@ int main()
     test_is_nothrow_destructible<int*>();
     test_is_nothrow_destructible<const int*>();
     test_is_nothrow_destructible<char[3]>();
-    test_is_nothrow_destructible<char[3]>();
     test_is_nothrow_destructible<Abstract>();
 #if __has_feature(cxx_noexcept)
     test_is_nothrow_destructible<bit_zero>();

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp Tue Sep  2 11:19:38 2014
@@ -48,5 +48,5 @@ int main()
     test_is_pod<int*>();
     test_is_pod<const int*>();
     test_is_pod<char[3]>();
-    test_is_pod<char[3]>();
+    test_is_pod<char[]>();
 }

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp Tue Sep  2 11:19:38 2014
@@ -69,7 +69,7 @@ int main()
     test_is_not_polymorphic<int*>();
     test_is_not_polymorphic<const int*>();
     test_is_not_polymorphic<char[3]>();
-    test_is_not_polymorphic<char[3]>();
+    test_is_not_polymorphic<char[]>();
     test_is_not_polymorphic<Union>();
     test_is_not_polymorphic<Empty>();
     test_is_not_polymorphic<bit_zero>();

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp Tue Sep  2 11:19:38 2014
@@ -45,7 +45,7 @@ int main()
     test_is_not_signed<int*>();
     test_is_not_signed<const int*>();
     test_is_not_signed<char[3]>();
-    test_is_not_signed<char[3]>();
+    test_is_not_signed<char[]>();
     test_is_not_signed<bool>();
     test_is_not_signed<unsigned>();
 

Removed: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp?rev=216908&view=auto
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp (removed)
@@ -1,63 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// type_traits
-
-// is_trivially_copyable
-
-#include <type_traits>
-#include <cassert>
-
-template <class T>
-void test_is_trivially_copyable()
-{
-    static_assert( std::is_trivially_copyable<T>::value, "");
-    static_assert( std::is_trivially_copyable<const T>::value, "");
-    static_assert(!std::is_trivially_copyable<volatile T>::value, "");
-    static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
-}
-
-template <class T>
-void test_is_not_trivially_copyable()
-{
-    static_assert(!std::is_trivially_copyable<T>::value, "");
-    static_assert(!std::is_trivially_copyable<const T>::value, "");
-    static_assert(!std::is_trivially_copyable<volatile T>::value, "");
-    static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
-}
-
-struct A
-{
-    int i_;
-};
-
-struct B
-{
-    int i_;
-    ~B() {assert(i_ == 0);}
-};
-
-class C
-{
-public:
-    C();
-};
-
-int main()
-{
-    test_is_trivially_copyable<int> ();
-    test_is_trivially_copyable<const int> ();
-    test_is_trivially_copyable<A> ();
-    test_is_trivially_copyable<const A> ();
-    test_is_trivially_copyable<C> ();
-
-    test_is_not_trivially_copyable<int&> ();
-    test_is_not_trivially_copyable<const A&> ();
-    test_is_not_trivially_copyable<B> ();
-}

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp Tue Sep  2 11:19:38 2014
@@ -23,7 +23,7 @@ void test_is_trivially_destructible()
 }
 
 template <class T>
-void test_has_not_trivial_destructor()
+void test_is_not_trivially_destructible()
 {
     static_assert(!std::is_trivially_destructible<T>::value, "");
     static_assert(!std::is_trivially_destructible<const T>::value, "");
@@ -64,10 +64,11 @@ struct A
 
 int main()
 {
-    test_has_not_trivial_destructor<void>();
-    test_has_not_trivial_destructor<A>();
-    test_has_not_trivial_destructor<AbstractDestructor>();
-    test_has_not_trivial_destructor<NotEmpty>();
+    test_is_not_trivially_destructible<void>();
+    test_is_not_trivially_destructible<A>();
+    test_is_not_trivially_destructible<AbstractDestructor>();
+    test_is_not_trivially_destructible<NotEmpty>();
+    test_is_not_trivially_destructible<char[]>();
 
     test_is_trivially_destructible<Abstract>();
     test_is_trivially_destructible<int&>();
@@ -78,6 +79,5 @@ int main()
     test_is_trivially_destructible<int*>();
     test_is_trivially_destructible<const int*>();
     test_is_trivially_destructible<char[3]>();
-    test_is_trivially_destructible<char[3]>();
     test_is_trivially_destructible<bit_zero>();
 }

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp Tue Sep  2 11:19:38 2014
@@ -45,7 +45,7 @@ int main()
     test_is_not_unsigned<int*>();
     test_is_not_unsigned<const int*>();
     test_is_not_unsigned<char[3]>();
-    test_is_not_unsigned<char[3]>();
+    test_is_not_unsigned<char[]>();
     test_is_not_unsigned<int>();
     test_is_not_unsigned<double>();
 

Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp?rev=216909&r1=216908&r2=216909&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp Tue Sep  2 11:19:38 2014
@@ -30,7 +30,7 @@ int main()
     test_is_volatile<int*>();
     test_is_volatile<const int*>();
     test_is_volatile<char[3]>();
-    test_is_volatile<char[3]>();
+    test_is_volatile<char[]>();
 
     static_assert(!std::is_volatile<int&>::value, "");
     static_assert(!std::is_volatile<volatile int&>::value, "");





More information about the cfe-commits mailing list