summaryrefslogtreecommitdiff
path: root/test/catch_pointer_nullptr.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-04-02 23:26:37 +0000
committerEric Fiselier <eric@efcs.ca>2015-04-02 23:26:37 +0000
commit0cb62d1b51f3d9ab65e0ba7b6541dda0663fe50d (patch)
tree8d48a09b601f4d6d548f5855d7a3b76efc0f0de7 /test/catch_pointer_nullptr.pass.cpp
parentc20d83676d5f48624bd57c5bd70201455ddc30c8 (diff)
[libcxxabi] Fix multi-level pointer conversions and pointer to member conversion detection.
Summary: Currently there are bugs in out detection of multi-level pointer conversions and pointer to member conversions. This patch fixes the following issues. * Allow multi-level pointers with different nested qualifiers. * Allow multi-level mixed pointers to objects and pointers to members with different nested qualifiers. * Allow conversions from `int Base::*` to `int Derived::*` but only for non-nested pointers. There is still some work that needs to be done to clean this patch up but I want to get some input on it. Open questions: * Does `__pointer_to_member_type_info::can_catch(...)` need to adjust the pointer if a base to derived conversion is performed? Reviewers: danalbert, compnerd, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D8758 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@233984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/catch_pointer_nullptr.pass.cpp')
-rw-r--r--test/catch_pointer_nullptr.pass.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/test/catch_pointer_nullptr.pass.cpp b/test/catch_pointer_nullptr.pass.cpp
index dae6e6a..b969119 100644
--- a/test/catch_pointer_nullptr.pass.cpp
+++ b/test/catch_pointer_nullptr.pass.cpp
@@ -8,6 +8,13 @@
//===----------------------------------------------------------------------===//
#include <cassert>
+#include <cstdlib>
+
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
+struct A {};
#if __has_feature(cxx_nullptr)
@@ -27,8 +34,6 @@ void test1()
}
}
-struct A {};
-
void test2()
{
try
@@ -45,6 +50,18 @@ void test2()
}
}
+template <class Catch>
+void catch_nullptr_test() {
+ try {
+ throw nullptr;
+ assert(false);
+ } catch (Catch) {
+ // nothing todo
+ } catch (...) {
+ assert(false);
+ }
+}
+
#else
void test1()
@@ -55,10 +72,22 @@ void test2()
{
}
+template <class Catch>
+void catch_nullptr_test()
+{
+}
+
#endif
int main()
{
- test1();
- test2();
+ // catch naked nullptrs
+ test1();
+ test2();
+
+ catch_nullptr_test<int*>();
+ catch_nullptr_test<int**>();
+ catch_nullptr_test<int A::*>();
+ catch_nullptr_test<const int A::*>();
+ catch_nullptr_test<int A::**>();
}