[libc++] Fix failures when running the test suite without RTTI
authorLouis Dionne <ldionne@apple.com>
Wed, 15 Jul 2020 15:26:20 +0000 (11:26 -0400)
committerLouis Dionne <ldionne@apple.com>
Tue, 22 Sep 2020 00:17:24 +0000 (20:17 -0400)
47 files changed:
libcxx/include/any
libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp
libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp
libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp
libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp
libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp
libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
libcxx/test/std/utilities/type.index/type.index.hash/hash.pass.cpp
libcxx/test/std/utilities/type.index/type.index.members/ctor.pass.cpp
libcxx/test/std/utilities/type.index/type.index.members/eq.pass.cpp
libcxx/test/std/utilities/type.index/type.index.members/hash_code.pass.cpp
libcxx/test/std/utilities/type.index/type.index.members/lt.pass.cpp
libcxx/test/std/utilities/type.index/type.index.members/name.pass.cpp
libcxx/test/std/utilities/type.index/type.index.overview/copy_assign.pass.cpp
libcxx/test/std/utilities/type.index/type.index.overview/copy_ctor.pass.cpp
libcxx/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
libcxx/test/std/utilities/utility/utility.inplace/inplace.pass.cpp
libcxx/test/support/demangle.h [deleted file]
libcxx/test/support/experimental_any_helpers.h
libcxx/test/support/test.support/test_demangle.pass.cpp [deleted file]
libcxx/test/support/test.support/test_macros_header.exceptions.pass.cpp [moved from libcxx/test/support/test.support/test_macros_header_exceptions.pass.cpp with 66% similarity]
libcxx/test/support/test.support/test_macros_header.no_exceptions.verify.cpp [moved from libcxx/test/support/test.support/test_macros_header_exceptions.fail.cpp with 58% similarity]
libcxx/test/support/test.support/test_macros_header.no_rtti.verify.cpp [moved from libcxx/test/support/test.support/test_macros_header_rtti.fail.cpp with 57% similarity]
libcxx/test/support/test.support/test_macros_header.rtti.pass.cpp [moved from libcxx/test/support/test.support/test_macros_header_rtti.pass.cpp with 69% similarity]
libcxx/test/support/test_macros.h
libcxx/test/support/type_id.h

index 7546f31..51731b7 100644 (file)
@@ -156,7 +156,7 @@ namespace __any_imp
   template <class _Tp>
   inline _LIBCPP_INLINE_VISIBILITY
   constexpr const void* __get_fallback_typeid() {
-      return &__unique_typeinfo<decay_t<_Tp>>::__id;
+      return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
   }
 
   template <class _Tp>
index 9a8e938..ecebc7c 100644 (file)
@@ -51,12 +51,12 @@ int main(int, char**)
         std::function<int(int)> f1 = g;
         std::function<int(int)> f2 = ^(int x) { return x + 1; };
         assert(globalMemCounter.checkOutstandingNewEq(0));
-        assert(*f1.target<int(*)(int)>() == g);
-        assert(*f2.target<int(^)(int)>() != 0);
+        RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+        RTTI_ASSERT(*f2.target<int(^)(int)>() != 0);
         swap(f1, f2);
         assert(globalMemCounter.checkOutstandingNewEq(0));
-        assert(*f1.target<int(^)(int)>() != 0);
-        assert(*f2.target<int(*)(int)>() == g);
+        RTTI_ASSERT(*f1.target<int(^)(int)>() != 0);
+        RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
     }
 
     // operator bool
@@ -107,13 +107,13 @@ int main(int, char**)
         std::function<int(int)> f2 = ^(int x) { return x + 1; };
         assert(A::count == 1);
         assert(globalMemCounter.checkOutstandingNewEq(1));
-        assert(f1.target<A>()->id() == 999);
-        assert((*f2.target<int(^)(int)>())(13) == 14);
+        RTTI_ASSERT(f1.target<A>()->id() == 999);
+        RTTI_ASSERT((*f2.target<int(^)(int)>())(13) == 14);
         f1.swap(f2);
         assert(A::count == 1);
         assert(globalMemCounter.checkOutstandingNewEq(1));
-        assert((*f1.target<int(^)(int)>())(13) == 14);
-        assert(f2.target<A>()->id() == 999);
+        RTTI_ASSERT((*f1.target<int(^)(int)>())(13) == 14);
+        RTTI_ASSERT(f2.target<A>()->id() == 999);
     }
     assert(globalMemCounter.checkOutstandingNewEq(0));
     assert(A::count == 0);
@@ -132,15 +132,15 @@ int main(int, char**)
     {
         int (^block)(int) = Block_copy(^(int x) { return x + 1; });
         std::function<int(int)> f = block;
-        assert(*f.target<int(^)(int)>() == block);
-        assert(f.target<int(*)(int)>() == 0);
+        RTTI_ASSERT(*f.target<int(^)(int)>() == block);
+        RTTI_ASSERT(f.target<int(*)(int)>() == 0);
         Block_release(block);
     }
 
     // target_type
     {
         std::function<int(int)> f = ^(int x) { return x + 1; };
-        assert(f.target_type() == typeid(int(^)(int)));
+        RTTI_ASSERT(f.target_type() == typeid(int(^)(int)));
     }
 
     return 0;
index 33ab765..e97ed0d 100644 (file)
@@ -39,12 +39,12 @@ bool A::cancel = false;
 int main(int, char**)
 {
   A::global = A();
-  assert(A::global.target<A>());
+  RTTI_ASSERT(A::global.target<A>());
 
   // Check that we don't recurse in A::~A().
   A::cancel = true;
   A::global = std::function<void()>(nullptr);
-  assert(!A::global.target<A>());
+  RTTI_ASSERT(!A::global.target<A>());
 
   return 0;
 }
index 0a2618d..3269f1d 100644 (file)
@@ -39,12 +39,12 @@ bool A::cancel = false;
 int main(int, char**)
 {
   A::global = A();
-  assert(A::global.target<A>());
+  RTTI_ASSERT(A::global.target<A>());
 
   // Check that we don't recurse in A::~A().
   A::cancel = true;
   A::global = nullptr;
-  assert(!A::global.target<A>());
+  RTTI_ASSERT(!A::global.target<A>());
 
   return 0;
 }
index 175e9f6..cec4b20 100644 (file)
@@ -156,8 +156,8 @@ void test_cast_non_copyable_type()
 void test_cast_array() {
     int arr[3];
     std::any a(arr);
-    assert(a.type() == typeid(int*)); // contained value is decayed
-//  We can't get an array out
+    RTTI_ASSERT(a.type() == typeid(int*)); // contained value is decayed
+    // We can't get an array out
     int (*p)[3] = std::any_cast<int[3]>(&a);
     assert(p == nullptr);
 }
index 02be30d..f577a55 100644 (file)
@@ -71,13 +71,13 @@ int main(int, char**)
 #endif
     assert(A::count == 2);
     assert(globalMemCounter.checkOutstandingNewEq(2));
-    assert(f1.target<A>()->id() == 1);
-    assert(f2.target<A>()->id() == 2);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(f2.target<A>()->id() == 2);
     swap(f1, f2);
     assert(A::count == 2);
     assert(globalMemCounter.checkOutstandingNewEq(2));
-    assert(f1.target<A>()->id() == 2);
-    assert(f2.target<A>()->id() == 1);
+    RTTI_ASSERT(f1.target<A>()->id() == 2);
+    RTTI_ASSERT(f2.target<A>()->id() == 1);
     }
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -89,13 +89,13 @@ int main(int, char**)
 #endif
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f1.target<A>()->id() == 1);
-    assert(*f2.target<int(*)(int)>() == g);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
     swap(f1, f2);
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(*f1.target<int(*)(int)>() == g);
-    assert(f2.target<A>()->id() == 1);
+    RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+    RTTI_ASSERT(f2.target<A>()->id() == 1);
     }
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -107,13 +107,13 @@ int main(int, char**)
 #endif
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(*f1.target<int(*)(int)>() == g);
-    assert(f2.target<A>()->id() == 1);
+    RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+    RTTI_ASSERT(f2.target<A>()->id() == 1);
     swap(f1, f2);
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f1.target<A>()->id() == 1);
-    assert(*f2.target<int(*)(int)>() == g);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
     }
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -125,13 +125,13 @@ int main(int, char**)
 #endif
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(*f1.target<int(*)(int)>() == g);
-    assert(*f2.target<int(*)(int)>() == h);
+    RTTI_ASSERT(*f1.target<int(*)(int)>() == g);
+    RTTI_ASSERT(*f2.target<int(*)(int)>() == h);
     swap(f1, f2);
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(*f1.target<int(*)(int)>() == h);
-    assert(*f2.target<int(*)(int)>() == g);
+    RTTI_ASSERT(*f1.target<int(*)(int)>() == h);
+    RTTI_ASSERT(*f2.target<int(*)(int)>() == g);
     }
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
index d4ed8e9..5ee20c7 100644 (file)
@@ -71,35 +71,35 @@ int main(int, char**)
     std::function<int(int)> f = A();
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.target<A>());
-    assert(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>());
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
     }
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
     {
     std::function<int(int)> f = g;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>());
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>());
+    RTTI_ASSERT(f.target<A>() == 0);
     }
     assert(globalMemCounter.checkOutstandingNewEq(0));
     {
     std::function<int(int)> f = (int (*)(int))0;
     assert(!f);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>() == 0);
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
     }
     {
     std::function<int(const A*, int)> f = &A::foo;
     assert(f);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int (A::*)(int) const>() != 0);
+    RTTI_ASSERT(f.target<int (A::*)(int) const>() != 0);
     }
     {
       std::function<void(int)> f(&g);
       assert(f);
-      assert(f.target<int(*)(int)>() != 0);
+      RTTI_ASSERT(f.target<int(*)(int)>() != 0);
       f(1);
     }
     {
index b3a374e..519b2f4 100644 (file)
@@ -75,8 +75,8 @@ int main(int, char**)
     f = A();
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.target<A>());
-    assert(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>());
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
     }
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -84,8 +84,8 @@ int main(int, char**)
     std::function<int(int)> f;
     f = g;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>());
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>());
+    RTTI_ASSERT(f.target<A>() == 0);
     }
     assert(globalMemCounter.checkOutstandingNewEq(0));
     {
@@ -93,21 +93,21 @@ int main(int, char**)
     f = (int (*)(int))0;
     assert(!f);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>() == 0);
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
     }
     {
     std::function<int(const A*, int)> f;
     f = &A::foo;
     assert(f);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int (A::*)(int) const>() != 0);
+    RTTI_ASSERT(f.target<int (A::*)(int) const>() != 0);
     }
     {
     std::function<void(int)> f;
     f = &g;
     assert(f);
-    assert(f.target<int(*)(int)>() != 0);
+    RTTI_ASSERT(f.target<int(*)(int)>() != 0);
     f(1);
     }
 #if TEST_STD_VER >= 11
index 59d6375..39f20b7 100644 (file)
@@ -167,14 +167,14 @@ void test_imp() {
     { // Check that the null value is detected
         TestFn tf = nullptr;
         std::function<Fn> f = tf;
-        assert(f.template target<TestFn>() == nullptr);
+        RTTI_ASSERT(f.template target<TestFn>() == nullptr);
     }
     { // Check that the non-null value is detected.
         TestFn tf = Creator<TestFn>::create();
         assert(tf != nullptr);
         std::function<Fn> f = tf;
-        assert(f.template target<TestFn>() != nullptr);
-        assert(*f.template target<TestFn>() == tf);
+        RTTI_ASSERT(f.template target<TestFn>() != nullptr);
+        RTTI_ASSERT(*f.template target<TestFn>() == tf);
     }
 }
 
index b2acb96..301cd75 100644 (file)
@@ -36,16 +36,16 @@ void test_FunctionObject(AllocType& alloc)
     std::function<FuncType> f = FunctionObject();
     assert(FunctionObject::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.template target<FunctionObject>());
-    assert(f.template target<FuncType>() == 0);
-    assert(f.template target<FuncType*>() == 0);
+    RTTI_ASSERT(f.template target<FunctionObject>());
+    RTTI_ASSERT(f.template target<FuncType>() == 0);
+    RTTI_ASSERT(f.template target<FuncType*>() == 0);
     // Copy function with allocator
     std::function<FuncType> f2(std::allocator_arg, alloc, f);
     assert(FunctionObject::count == 2);
     assert(globalMemCounter.checkOutstandingNewEq(2));
-    assert(f2.template target<FunctionObject>());
-    assert(f2.template target<FuncType>() == 0);
-    assert(f2.template target<FuncType*>() == 0);
+    RTTI_ASSERT(f2.template target<FunctionObject>());
+    RTTI_ASSERT(f2.template target<FuncType>() == 0);
+    RTTI_ASSERT(f2.template target<FuncType*>() == 0);
     }
     assert(FunctionObject::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -60,15 +60,15 @@ void test_FreeFunction(AllocType& alloc)
     FuncType* target = &FreeFunction;
     std::function<FuncType> f = target;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.template target<FuncType*>());
-    assert(*f.template target<FuncType*>() == target);
-    assert(f.template target<FuncType>() == 0);
+    RTTI_ASSERT(f.template target<FuncType*>());
+    RTTI_ASSERT(*f.template target<FuncType*>() == target);
+    RTTI_ASSERT(f.template target<FuncType>() == 0);
     // Copy function with allocator
     std::function<FuncType> f2(std::allocator_arg, alloc, f);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f2.template target<FuncType*>());
-    assert(*f2.template target<FuncType*>() == target);
-    assert(f2.template target<FuncType>() == 0);
+    RTTI_ASSERT(f2.template target<FuncType*>());
+    RTTI_ASSERT(*f2.template target<FuncType*>() == target);
+    RTTI_ASSERT(f2.template target<FuncType>() == 0);
     }
     assert(globalMemCounter.checkOutstandingNewEq(0));
 }
@@ -82,15 +82,15 @@ void test_MemFunClass(AllocType& alloc)
     TargetType target = &MemFunClass::foo;
     std::function<FuncType> f = target;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.template target<TargetType>());
-    assert(*f.template target<TargetType>() == target);
-    assert(f.template target<FuncType*>() == 0);
+    RTTI_ASSERT(f.template target<TargetType>());
+    RTTI_ASSERT(*f.template target<TargetType>() == target);
+    RTTI_ASSERT(f.template target<FuncType*>() == 0);
     // Copy function with allocator
     std::function<FuncType> f2(std::allocator_arg, alloc, f);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f2.template target<TargetType>());
-    assert(*f2.template target<TargetType>() == target);
-    assert(f2.template target<FuncType*>() == 0);
+    RTTI_ASSERT(f2.template target<TargetType>());
+    RTTI_ASSERT(*f2.template target<TargetType>() == target);
+    RTTI_ASSERT(f2.template target<FuncType*>() == 0);
     }
     assert(globalMemCounter.checkOutstandingNewEq(0));
 }
index c40362d..7ccb678 100644 (file)
@@ -62,16 +62,16 @@ int main(int, char**)
     std::function<int(int)> f = A();
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.target<A>());
-    assert(f.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>());
+    RTTI_ASSERT(f.target<int (*)(int)>() == 0);
     std::function<int(int)> f2(std::allocator_arg, bare_allocator<A>(),
                                std::move(f));
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f2.target<A>());
-    assert(f2.target<int (*)(int)>() == 0);
-    assert(f.target<A>() == 0);
-    assert(f.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f2.target<A>());
+    RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int (*)(int)>() == 0);
   }
     assert(globalMemCounter.checkOutstandingNewEq(0));
     {
@@ -83,14 +83,14 @@ int main(int, char**)
         Ref aref(a);
         std::function<int(int)> f(aref);
         assert(A::count == 1);
-        assert(f.target<A>() == nullptr);
-        assert(f.target<Ref>());
+        RTTI_ASSERT(f.target<A>() == nullptr);
+        RTTI_ASSERT(f.target<Ref>());
         std::function<int(int)> f2(std::allocator_arg, std::allocator<int>{},
                                    std::move(f));
         assert(A::count == 1);
-        assert(f2.target<A>() == nullptr);
-        assert(f2.target<Ref>());
-        assert(f.target<Ref>()); // f is unchanged because the target is small
+        RTTI_ASSERT(f2.target<A>() == nullptr);
+        RTTI_ASSERT(f2.target<Ref>());
+        RTTI_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
     }
     {
         // Test that moving a function constructed from a function pointer
@@ -99,13 +99,13 @@ int main(int, char**)
         using Ptr = int(*)(int);
         Ptr p = g;
         std::function<int(int)> f(p);
-        assert(f.target<A>() == nullptr);
-        assert(f.target<Ptr>());
+        RTTI_ASSERT(f.target<A>() == nullptr);
+        RTTI_ASSERT(f.target<Ptr>());
         std::function<int(int)> f2(std::allocator_arg, std::allocator<int>(),
                                    std::move(f));
-        assert(f2.target<A>() == nullptr);
-        assert(f2.target<Ptr>());
-        assert(f.target<Ptr>()); // f is unchanged because the target is small
+        RTTI_ASSERT(f2.target<A>() == nullptr);
+        RTTI_ASSERT(f2.target<Ptr>());
+        RTTI_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
     }
 
   return 0;
index e845395..9a27c4d 100644 (file)
@@ -58,67 +58,67 @@ int main(int, char**) {
     std::function<int(int)> f = A();
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.target<A>());
-    assert(f.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>());
+    RTTI_ASSERT(f.target<int (*)(int)>() == 0);
     std::function<int(int)> f2;
     f2 = f;
     assert(A::count == 2);
     assert(globalMemCounter.checkOutstandingNewEq(2));
-    assert(f2.target<A>());
-    assert(f2.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f2.target<A>());
+    RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
   }
   assert(A::count == 0);
   assert(globalMemCounter.checkOutstandingNewEq(0));
   {
     std::function<int(int)> f = g;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int (*)(int)>());
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int (*)(int)>());
+    RTTI_ASSERT(f.target<A>() == 0);
     std::function<int(int)> f2;
     f2 = f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f2.target<int (*)(int)>());
-    assert(f2.target<A>() == 0);
+    RTTI_ASSERT(f2.target<int (*)(int)>());
+    RTTI_ASSERT(f2.target<A>() == 0);
   }
   assert(globalMemCounter.checkOutstandingNewEq(0));
   {
     std::function<int(int)> f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int (*)(int)>() == 0);
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
     std::function<int(int)> f2;
     f2 = f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f2.target<int (*)(int)>() == 0);
-    assert(f2.target<A>() == 0);
+    RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f2.target<A>() == 0);
   }
   {
     typedef std::function<int()> Func;
     Func f = g0;
     Func& fr = (f = (Func &)f);
     assert(&fr == &f);
-    assert(*f.target<int(*)()>() == g0);
+    RTTI_ASSERT(*f.target<int(*)()>() == g0);
   }
   {
     typedef std::function<int(int)> Func;
     Func f = g;
     Func& fr = (f = (Func &)f);
     assert(&fr == &f);
-    assert(*f.target<int(*)(int)>() == g);
+    RTTI_ASSERT(*f.target<int(*)(int)>() == g);
   }
   {
     typedef std::function<int(int, int)> Func;
     Func f = g2;
     Func& fr = (f = (Func &)f);
     assert(&fr == &f);
-    assert(*f.target<int(*)(int, int)>() == g2);
+    RTTI_ASSERT(*f.target<int(*)(int, int)>() == g2);
   }
   {
     typedef std::function<int(int, int, int)> Func;
     Func f = g3;
     Func& fr = (f = (Func &)f);
     assert(&fr == &f);
-    assert(*f.target<int(*)(int, int, int)>() == g3);
+    RTTI_ASSERT(*f.target<int(*)(int, int, int)>() == g3);
   }
 #if TEST_STD_VER >= 11
   assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -126,16 +126,16 @@ int main(int, char**) {
     std::function<int(int)> f = A();
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.target<A>());
-    assert(f.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>());
+    RTTI_ASSERT(f.target<int (*)(int)>() == 0);
     std::function<int(int)> f2;
     f2 = std::move(f);
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f2.target<A>());
-    assert(f2.target<int (*)(int)>() == 0);
-    assert(f.target<A>() == 0);
-    assert(f.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f2.target<A>());
+    RTTI_ASSERT(f2.target<int (*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int (*)(int)>() == 0);
   }
 #endif
 
index 58421a2..494b243 100644 (file)
@@ -61,47 +61,47 @@ int main(int, char**)
     std::function<int(int)> f = A();
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.target<A>());
-    assert(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>());
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
     std::function<int(int)> f2 = f;
     assert(A::count == 2);
     assert(globalMemCounter.checkOutstandingNewEq(2));
-    assert(f2.target<A>());
-    assert(f2.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f2.target<A>());
+    RTTI_ASSERT(f2.target<int(*)(int)>() == 0);
     }
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
     {
     std::function<int(int)> f = g;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>());
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>());
+    RTTI_ASSERT(f.target<A>() == 0);
     std::function<int(int)> f2 = f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f2.target<int(*)(int)>());
-    assert(f2.target<A>() == 0);
+    RTTI_ASSERT(f2.target<int(*)(int)>());
+    RTTI_ASSERT(f2.target<A>() == 0);
     }
     assert(globalMemCounter.checkOutstandingNewEq(0));
     {
     std::function<int(int)> f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>() == 0);
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
     std::function<int(int)> f2 = f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f2.target<int(*)(int)>() == 0);
-    assert(f2.target<A>() == 0);
+    RTTI_ASSERT(f2.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f2.target<A>() == 0);
     }
     {
     std::function<int(int)> f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>() == 0);
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
     assert(!f);
     std::function<long(int)> g = f;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(g.target<long(*)(int)>() == 0);
-    assert(g.target<A>() == 0);
+    RTTI_ASSERT(g.target<long(*)(int)>() == 0);
+    RTTI_ASSERT(g.target<A>() == 0);
     assert(!g);
     }
 #if TEST_STD_VER >= 11
@@ -110,8 +110,8 @@ int main(int, char**)
         std::function<int(int)> f = A();
         assert(A::count == 1);
         assert(globalMemCounter.checkOutstandingNewEq(1));
-        assert(f.target<A>());
-        assert(f.target<int(*)(int)>() == 0);
+        RTTI_ASSERT(f.target<A>());
+        RTTI_ASSERT(f.target<int(*)(int)>() == 0);
                LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
 #if TEST_STD_VER > 17
                ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
@@ -119,10 +119,10 @@ int main(int, char**)
         std::function<int(int)> f2 = std::move(f);
         assert(A::count == 1);
         assert(globalMemCounter.checkOutstandingNewEq(1));
-        assert(f2.target<A>());
-        assert(f2.target<int(*)(int)>() == 0);
-        assert(f.target<A>() == 0);
-        assert(f.target<int(*)(int)>() == 0);
+        RTTI_ASSERT(f2.target<A>());
+        RTTI_ASSERT(f2.target<int(*)(int)>() == 0);
+        RTTI_ASSERT(f.target<A>() == 0);
+        RTTI_ASSERT(f.target<int(*)(int)>() == 0);
     }
     assert(globalMemCounter.checkOutstandingNewEq(0));
     {
@@ -134,17 +134,19 @@ int main(int, char**)
         Ref aref(a);
         std::function<int(int)> f(aref);
         assert(A::count == 1);
-        assert(f.target<A>() == nullptr);
-        assert(f.target<Ref>());
+        RTTI_ASSERT(f.target<A>() == nullptr);
+        RTTI_ASSERT(f.target<Ref>());
                LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
 #if TEST_STD_VER > 17
                ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
 #endif
         std::function<int(int)> f2(std::move(f));
         assert(A::count == 1);
-        assert(f2.target<A>() == nullptr);
-        assert(f2.target<Ref>());
-        LIBCPP_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
+        RTTI_ASSERT(f2.target<A>() == nullptr);
+        RTTI_ASSERT(f2.target<Ref>());
+#if defined(_LIBCPP_VERSION)
+        RTTI_ASSERT(f.target<Ref>()); // f is unchanged because the target is small
+#endif
     }
     {
         // Test that moving a function constructed from a function pointer
@@ -153,16 +155,18 @@ int main(int, char**)
         using Ptr = int(*)(int);
         Ptr p = g;
         std::function<int(int)> f(p);
-        assert(f.target<A>() == nullptr);
-        assert(f.target<Ptr>());
+        RTTI_ASSERT(f.target<A>() == nullptr);
+        RTTI_ASSERT(f.target<Ptr>());
                LIBCPP_ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
 #if TEST_STD_VER > 17
                ASSERT_NOEXCEPT(std::function<int(int)>(std::move(f)));
 #endif
         std::function<int(int)> f2(std::move(f));
-        assert(f2.target<A>() == nullptr);
-        assert(f2.target<Ptr>());
-        LIBCPP_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
+        RTTI_ASSERT(f2.target<A>() == nullptr);
+        RTTI_ASSERT(f2.target<Ptr>());
+#if defined(_LIBCPP_VERSION)
+        RTTI_ASSERT(f.target<Ptr>()); // f is unchanged because the target is small
+#endif
     }
 #endif  // TEST_STD_VER >= 11
 
index 0cc2eb1..b0ffc2c 100644 (file)
@@ -59,20 +59,20 @@ int main(int, char**)
     std::function<int(int)> f = A();
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f.target<A>());
+    RTTI_ASSERT(f.target<A>());
     f = nullptr;
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<A>() == 0);
     }
     {
     std::function<int(int)> f = g;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>());
-    assert(f.target<A>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>());
+    RTTI_ASSERT(f.target<A>() == 0);
     f = nullptr;
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(f.target<int(*)(int)>() == 0);
+    RTTI_ASSERT(f.target<int(*)(int)>() == 0);
     }
 
   return 0;
index bf1489c..01a1fab 100644 (file)
@@ -70,13 +70,13 @@ int main(int, char**) {
     std::function<int(int)> f2 = A(2);
     assert(A::count == 2);
     assert(globalMemCounter.checkOutstandingNewEq(2));
-    assert(f1.target<A>()->id() == 1);
-    assert(f2.target<A>()->id() == 2);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(f2.target<A>()->id() == 2);
     f1.swap(f2);
     assert(A::count == 2);
     assert(globalMemCounter.checkOutstandingNewEq(2));
-    assert(f1.target<A>()->id() == 2);
-    assert(f2.target<A>()->id() == 1);
+    RTTI_ASSERT(f1.target<A>()->id() == 2);
+    RTTI_ASSERT(f2.target<A>()->id() == 1);
   }
   assert(A::count == 0);
   assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -85,13 +85,13 @@ int main(int, char**) {
     std::function<int(int)> f2 = g;
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f1.target<A>()->id() == 1);
-    assert(*f2.target<int (*)(int)>() == g);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(*f2.target<int (*)(int)>() == g);
     f1.swap(f2);
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(*f1.target<int (*)(int)>() == g);
-    assert(f2.target<A>()->id() == 1);
+    RTTI_ASSERT(*f1.target<int (*)(int)>() == g);
+    RTTI_ASSERT(f2.target<A>()->id() == 1);
   }
   assert(A::count == 0);
   assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -100,13 +100,13 @@ int main(int, char**) {
     std::function<int(int)> f2 = A(1);
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(*f1.target<int (*)(int)>() == g);
-    assert(f2.target<A>()->id() == 1);
+    RTTI_ASSERT(*f1.target<int (*)(int)>() == g);
+    RTTI_ASSERT(f2.target<A>()->id() == 1);
     f1.swap(f2);
     assert(A::count == 1);
     assert(globalMemCounter.checkOutstandingNewEq(1));
-    assert(f1.target<A>()->id() == 1);
-    assert(*f2.target<int (*)(int)>() == g);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(*f2.target<int (*)(int)>() == g);
   }
   assert(A::count == 0);
   assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -115,13 +115,13 @@ int main(int, char**) {
     std::function<int(int)> f2 = h;
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(*f1.target<int (*)(int)>() == g);
-    assert(*f2.target<int (*)(int)>() == h);
+    RTTI_ASSERT(*f1.target<int (*)(int)>() == g);
+    RTTI_ASSERT(*f2.target<int (*)(int)>() == h);
     f1.swap(f2);
     assert(A::count == 0);
     assert(globalMemCounter.checkOutstandingNewEq(0));
-    assert(*f1.target<int (*)(int)>() == h);
-    assert(*f2.target<int (*)(int)>() == g);
+    RTTI_ASSERT(*f1.target<int (*)(int)>() == h);
+    RTTI_ASSERT(*f2.target<int (*)(int)>() == g);
   }
   assert(A::count == 0);
   assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -134,7 +134,7 @@ int main(int, char**) {
       f1.swap(f1);
     }
     assert(A::count == 1);
-    assert(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
   }
   assert(A::count == 0);
   assert(globalMemCounter.checkOutstandingNewEq(0));
@@ -143,7 +143,7 @@ int main(int, char**) {
     DisableAllocationGuard guard;
     ((void)guard);
     f1.swap(f1);
-    assert(*f1.target<int (*)()>() == g0);
+    RTTI_ASSERT(*f1.target<int (*)()>() == g0);
   }
   assert(globalMemCounter.checkOutstandingNewEq(0));
   {
@@ -151,7 +151,7 @@ int main(int, char**) {
     DisableAllocationGuard guard;
     ((void)guard);
     f1.swap(f1);
-    assert(*f1.target<int (*)(int, int)>() == g2);
+    RTTI_ASSERT(*f1.target<int (*)(int, int)>() == g2);
   }
   assert(globalMemCounter.checkOutstandingNewEq(0));
   {
@@ -159,7 +159,7 @@ int main(int, char**) {
     DisableAllocationGuard guard;
     ((void)guard);
     f1.swap(f1);
-    assert(*f1.target<int (*)(int, int, int)>() == g3);
+    RTTI_ASSERT(*f1.target<int (*)(int, int, int)>() == g3);
   }
   assert(globalMemCounter.checkOutstandingNewEq(0));
   {
@@ -169,7 +169,7 @@ int main(int, char**) {
     ((void)guard);
     f1.swap(f1);
     assert(A::count == 1);
-    assert(f1.target<A>()->id() == 1);
+    RTTI_ASSERT(f1.target<A>()->id() == 1);
   }
   assert(globalMemCounter.checkOutstandingNewEq(0));
   assert(A::count == 0);
@@ -180,7 +180,7 @@ int main(int, char**) {
     ((void)guard);
     f1.swap(f1);
     assert(A::count == 1);
-    assert(f1.target<A>()->id() == 2);
+    RTTI_ASSERT(f1.target<A>()->id() == 2);
   }
   assert(globalMemCounter.checkOutstandingNewEq(0));
   assert(A::count == 0);
@@ -191,7 +191,7 @@ int main(int, char**) {
     ((void)guard);
     f1.swap(f1);
     assert(A::count == 1);
-    assert(f1.target<A>()->id() == 3);
+    RTTI_ASSERT(f1.target<A>()->id() == 3);
   }
   assert(globalMemCounter.checkOutstandingNewEq(0));
   assert(A::count == 0);
index 4f87e68..cc238dd 100644 (file)
@@ -22,6 +22,8 @@
 // This test runs in C++03, but we have deprecated using std::function in C++03.
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
+// UNSUPPORTED: -fno-rtti
+
 #include <functional>
 #include <new>
 #include <cstdlib>
index 8290d46..ca3a6a5 100644 (file)
@@ -15,6 +15,8 @@
 // This test runs in C++03, but we have deprecated using std::function in C++03.
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
+// UNSUPPORTED: -fno-rtti
+
 #include <functional>
 #include <typeinfo>
 #include <cassert>
index 6667418..b84e165 100644 (file)
@@ -35,11 +35,13 @@ int main(int, char**)
     assert(A::count == 0);
     assert(p.use_count() == 1);
     assert(p.get() == 0);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count == 1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 3);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
index 23fff8c..fb5e4f4 100644 (file)
@@ -35,11 +35,13 @@ int main(int, char**)
     assert(A::count == 0);
     assert(p.use_count() == 1);
     assert(p.get() == 0);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count == 1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 3);
+#endif
     assert(test_allocator<A>::count == 1);
     assert(test_allocator<A>::alloc_count == 1);
     }
@@ -55,11 +57,13 @@ int main(int, char**)
     assert(A::count == 0);
     assert(p.use_count() == 1);
     assert(p.get() == 0);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count ==1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 1);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
@@ -72,11 +76,13 @@ int main(int, char**)
     assert(A::count == 0);
     assert(p.use_count() == 1);
     assert(p.get() == 0);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count ==1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 1);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
index e736eb5..58b1bb9 100644 (file)
@@ -39,11 +39,13 @@ int main(int, char**)
     assert(A::count == 1);
     assert(p.use_count() == 1);
     assert(p.get() == ptr);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count == 1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 3);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
index af9bfe9..4d0a292 100644 (file)
@@ -39,11 +39,13 @@ int main(int, char**)
     assert(A::count == 1);
     assert(p.use_count() == 1);
     assert(p.get() == ptr);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count == 1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 3);
+#endif
     assert(test_allocator<A>::count == 1);
     assert(test_allocator<A>::alloc_count == 1);
     }
@@ -60,11 +62,13 @@ int main(int, char**)
     assert(A::count == 1);
     assert(p.use_count() == 1);
     assert(p.get() == ptr);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count == 1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 3);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
@@ -78,11 +82,13 @@ int main(int, char**)
     assert(A::count == 1);
     assert(p.use_count() == 1);
     assert(p.get() == ptr);
-    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(test_deleter<A>::count == 1);
     assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
     assert(d);
     assert(d->state() == 3);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
index 97cd298..c337e19 100644 (file)
@@ -50,11 +50,13 @@ int main(int, char**)
         assert(B::count == 1);
         assert(p.use_count() == 1);
         assert(p.get() == ptr);
-        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
         assert(test_deleter<A>::count == 1);
         assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
         assert(d);
         assert(d->state() == 3);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
@@ -67,11 +69,13 @@ int main(int, char**)
         assert(B::count == 1);
         assert(p.use_count() == 1);
         assert(p.get() == ptr);
-        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
         assert(test_deleter<A>::count == 1);
         assert(test_deleter<A>::dealloc_count == 1);
+#ifndef TEST_HAS_NO_RTTI
+        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
         assert(d);
         assert(d->state() == 3);
+#endif
     }
     assert(A::count == 0);
     assert(test_deleter<A>::count == 0);
index ee7f376..7fa0873 100644 (file)
@@ -51,11 +51,13 @@ int main(int, char**)
         assert(B::count == 1);
         assert(p.use_count() == 1);
         assert(p.get() == ptr);
-        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
         assert(test_deleter<A>::count == 1);
         assert(test_deleter<A>::dealloc_count == 0);
+#ifndef TEST_HAS_NO_RTTI
+        std::get_deleter<test_deleter<A> >(p)
         assert(d);
         assert(d->state() == 3);
+#endif
         assert(test_allocator<A>::count == 1);
         assert(test_allocator<A>::alloc_count == 1);
     }
@@ -72,11 +74,13 @@ int main(int, char**)
         assert(B::count == 1);
         assert(p.use_count() == 1);
         assert(p.get() == ptr);
-        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
         assert(test_deleter<A>::count == 1);
         assert(test_deleter<A>::dealloc_count == 1);
+#ifndef TEST_HAS_NO_RTTI
+        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
         assert(d);
         assert(d->state() == 3);
+#endif
         assert(test_allocator<A>::count == 1);
         assert(test_allocator<A>::alloc_count == 1);
     }
index 8016224..bf6d495 100644 (file)
@@ -33,11 +33,13 @@ int main(int, char**)
       const std::shared_ptr<int> p;
       assert(!p);
     }
+#if !defined(TEST_HAS_NO_RTTI)
     {
       std::shared_ptr<A> basePtr = std::make_shared<B>();
       std::shared_ptr<B> sp = std::dynamic_pointer_cast<B>(basePtr);
       assert(sp);
     }
+#endif
 
     return 0;
 }
index 0154ae5..35ba517 100644 (file)
@@ -17,6 +17,8 @@
 //     size_t operator()(type_index index) const;
 // };
 
+// UNSUPPORTED: -fno-rtti
+
 #include <typeindex>
 #include <type_traits>
 #include <cassert>
index fd1ce7a..e1ed6b8 100644 (file)
@@ -12,6 +12,8 @@
 
 // type_index(const type_info& rhs);
 
+// UNSUPPORTED: -fno-rtti
+
 #include <typeinfo>
 #include <typeindex>
 #include <cassert>
index 80ca023..5224183 100644 (file)
@@ -13,6 +13,8 @@
 // bool operator==(const type_index& rhs) const;
 // bool operator!=(const type_index& rhs) const;
 
+// UNSUPPORTED: -fno-rtti
+
 #include <typeindex>
 #include <cassert>
 
index 1697624..1a96ca0 100644 (file)
@@ -15,6 +15,8 @@
 // bool operator> (const type_index& rhs) const;
 // bool operator>=(const type_index& rhs) const;
 
+// UNSUPPORTED: -fno-rtti
+
 #include <typeindex>
 #include <cassert>
 
index 9be1039..007c7a5 100644 (file)
@@ -34,7 +34,6 @@
 #include <memory>
 
 #include "test_macros.h"
-#include "type_id.h"
 
 template <class Tp, class Up>
 constexpr bool check_tag(Up) {
diff --git a/libcxx/test/support/demangle.h b/libcxx/test/support/demangle.h
deleted file mode 100644 (file)
index f8e90a1..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#ifndef SUPPORT_DEMANGLE_H
-#define SUPPORT_DEMANGLE_H
-
-#include "test_macros.h"
-#include <string>
-#include <cstdlib>
-
-#if !defined(TEST_HAS_NO_DEMANGLE)
-# if defined(__GNUC__) || defined(__clang__)
-#   if __has_include("cxxabi.h") && !defined(_LIBCPP_ABI_MICROSOFT)
-#     include "cxxabi.h"
-#   else
-#     define TEST_HAS_NO_DEMANGLE
-#   endif
-# else
-#   define TEST_HAS_NO_DEMANGLE
-# endif
-#endif
-
-#if defined(TEST_HAS_NO_DEMANGLE)
-inline std::string demangle(const char* mangled_name) {
-  return mangled_name;
-}
-#else
-template <size_t N> struct Printer;
-inline std::string demangle(const char* mangled_name) {
-  int status = 0;
-  char* out = __cxxabiv1::__cxa_demangle(mangled_name, nullptr, nullptr, &status);
-  if (out != nullptr) {
-    std::string res(out);
-    std::free(out);
-    return res;
-  }
-  return mangled_name;
-}
-#endif
-
-#endif // SUPPORT_DEMANGLE_H
index eeffd8c..9e1cebb 100644 (file)
 
 #include "test_macros.h"
 
-#if !defined(TEST_HAS_NO_RTTI)
-#define RTTI_ASSERT(X) assert(X)
-#else
-#define RTTI_ASSERT(X)
-#endif
-
 template <class T>
   struct IsSmallObject
     : public std::integral_constant<bool
diff --git a/libcxx/test/support/test.support/test_demangle.pass.cpp b/libcxx/test/support/test.support/test_demangle.pass.cpp
deleted file mode 100644 (file)
index fd67a3d..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-#include "test_macros.h"
-#include "demangle.h"
-#include <typeinfo>
-#include <cassert>
-
-struct MyType {};
-
-template <class T, class U> struct ArgumentListID {};
-
-int main(int, char**) {
-  struct {
-    const char* raw;
-    const char* expect;
-  } TestCases[] = {
-      {typeid(int).name(), "int"},
-      {typeid(MyType).name(), "MyType"},
-      {typeid(ArgumentListID<int, MyType>).name(), "ArgumentListID<int, MyType>"}
-  };
-  const size_t size = sizeof(TestCases) / sizeof(TestCases[0]);
-  for (size_t i=0; i < size; ++i) {
-    const char* raw = TestCases[i].raw;
-    const char* expect = TestCases[i].expect;
-#ifdef TEST_HAS_NO_DEMANGLE
-    assert(demangle(raw) == raw);
-    ((void)expect);
-#else
-    assert(demangle(raw) == expect);
-#endif
-  }
-
-  return 0;
-}
@@ -6,20 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: no-exceptions
-
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_EXCEPTIONS macro is NOT defined when exceptions
+// are enabled.
 
-// #define TEST_HAS_NO_EXCEPTIONS
+// UNSUPPORTED: no-exceptions
 
 #include "test_macros.h"
 
-#if defined(TEST_HAS_NO_EXCEPTIONS)
-#error macro defined unexpectedly
+#ifdef TEST_HAS_NO_EXCEPTIONS
+#  error "TEST_HAS_NO_EXCEPTIONS should NOT be defined"
 #endif
 
 int main(int, char**) {
-    try { ((void)0); } catch (...) {}
-
-  return 0;
+    try { (void)0; } catch (...) { }
+    return 0;
 }
@@ -6,20 +6,18 @@
 //
 //===----------------------------------------------------------------------===//
 
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_EXCEPTIONS macro is defined when exceptions are
+// disabled.
 
-// #define TEST_HAS_NO_EXCEPTIONS
+// REQUIRES: no-exceptions
 
 #include "test_macros.h"
 
-int main(int, char**) {
-#if defined(TEST_HAS_NO_EXCEPTIONS)
-    try { ((void)0); } catch (...) {} // expected-error {{exceptions disabled}}
-#else
-    try { ((void)0); } catch (...) {}
-#error exceptions enabled
-// expected-error@-1 {{exceptions enabled}}
+#ifndef TEST_HAS_NO_EXCEPTIONS
+#  error "TEST_HAS_NO_EXCEPTIONS should be defined"
 #endif
 
-  return 0;
+int main(int, char**) {
+    try { (void)0; } catch (...) { } // expected-error {{exceptions disabled}}
+    return 0;
 }
@@ -6,25 +6,22 @@
 //
 //===----------------------------------------------------------------------===//
 
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_RTTI macro is defined when the -fno-rtti feature
+// is defined.
 
-// #define TEST_HAS_NO_RTTI
+// REQUIRES: -fno-rtti
 
 #include "test_macros.h"
 
-struct A { virtual ~A() {} };
-struct B : A {};
+#ifndef TEST_HAS_NO_RTTI
+#  error "TEST_HAS_NO_RTTI should be defined"
+#endif
+
+struct A { virtual ~A() { } };
+struct B : A { };
 
 int main(int, char**) {
-#if defined(TEST_HAS_NO_RTTI)
-    A* ptr = new B;
-    (void)dynamic_cast<B*>(ptr); // expected-error{{cannot use dynamic_cast}}
-#else
     A* ptr = new B;
-    (void)dynamic_cast<B*>(ptr);
-#error RTTI enabled
-// expected-error@-1{{RTTI enabled}}
-#endif
-
-  return 0;
+    (void)dynamic_cast<B*>(ptr); // expected-error{{use of dynamic_cast requires -frtti}}
+    return 0;
 }
@@ -6,25 +6,23 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: -fno-rtti
-
-// "support/test_macros.hpp"
+// Make sure the TEST_HAS_NO_RTTI macro is NOT defined when the -fno-rtti
+// feature isn't defined.
 
-// #define TEST_HAS_NO_RTTI
+// UNSUPPORTED: -fno-rtti
 
 #include "test_macros.h"
 
-#if defined(TEST_HAS_NO_RTTI)
-#error Macro defined unexpectedly
+#ifdef TEST_HAS_NO_RTTI
+#  error "TEST_HAS_NO_RTTI should NOT be defined"
 #endif
 
-struct A { virtual ~A() {} };
-struct B : A {};
+struct A { virtual ~A() { } };
+struct B : A { };
 
 int main(int, char**) {
     A* ptr = new B;
     (void)dynamic_cast<B*>(ptr);
     delete ptr;
-
-  return 0;
+    return 0;
 }
index 0087360..f50f48f 100644 (file)
 #define TEST_HAS_NO_RTTI
 #endif
 
+#if !defined(TEST_HAS_NO_RTTI)
+# define RTTI_ASSERT(X) assert(X)
+#else
+# define RTTI_ASSERT(X)
+#endif
+
 #if !TEST_HAS_FEATURE(cxx_exceptions) && !defined(__cpp_exceptions) \
      && !defined(__EXCEPTIONS)
 #define TEST_HAS_NO_EXCEPTIONS
index 0af7df2..68bc98d 100644 (file)
@@ -9,13 +9,11 @@
 #define SUPPORT_TYPE_ID_H
 
 #include <functional>
-#include <typeinfo>
 #include <string>
 #include <cstdio>
 #include <cassert>
 
 #include "test_macros.h"
-#include "demangle.h"
 
 #if TEST_STD_VER < 11
 #error This header requires C++11 or greater
@@ -30,12 +28,7 @@ struct TypeID {
   {return LHS.m_id != RHS.m_id; }
 
   std::string name() const {
-    return demangle(m_id);
-  }
-
-  void dump() const {
-    std::string s = name();
-    std::printf("TypeID: %s\n", s.c_str());
+    return m_id;
   }
 
 private:
@@ -55,7 +48,7 @@ private:
 #endif // _MSC_VER
 template <class T>
 inline TypeID const& makeTypeIDImp() {
-  static const TypeID id(typeid(T).name());
+  static const TypeID id(__PRETTY_FUNCTION__);
   return id;
 }
 #ifdef _MSC_VER