diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-04-02 23:26:37 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-04-02 23:26:37 +0000 |
commit | 0cb62d1b51f3d9ab65e0ba7b6541dda0663fe50d (patch) | |
tree | 8d48a09b601f4d6d548f5855d7a3b76efc0f0de7 /test/catch_member_data_pointer_01.pass.cpp | |
parent | c20d83676d5f48624bd57c5bd70201455ddc30c8 (diff) | |
download | libcxxabi-0cb62d1b51f3d9ab65e0ba7b6541dda0663fe50d.tar.gz |
[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_member_data_pointer_01.pass.cpp')
-rw-r--r-- | test/catch_member_data_pointer_01.pass.cpp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/test/catch_member_data_pointer_01.pass.cpp b/test/catch_member_data_pointer_01.pass.cpp index 44ff753..298a1c0 100644 --- a/test/catch_member_data_pointer_01.pass.cpp +++ b/test/catch_member_data_pointer_01.pass.cpp @@ -18,6 +18,15 @@ struct A typedef const int A::*md1; typedef int A::*md2; +struct B : public A +{ + const int k; + int l; +}; + +typedef const int B::*der1; +typedef int B::*der2; + void test1() { try @@ -34,19 +43,126 @@ void test1() } } +// Check that cv qualified conversions are allowed. void test2() { try { throw &A::j; + } + catch (md2) + { + } + catch (...) + { + assert(false); + } + + try + { + throw &A::j; assert(false); } catch (md1) { + } + catch (...) + { + assert(false); + } +} + +// Check that Base -> Derived conversions are allowed. +void test3() +{ + try + { + throw &A::i; assert(false); } catch (md2) { + assert(false); + } + catch (der2) + { + assert(false); + } + catch (der1) + { + } + catch (md1) + { + assert(false); + } +} + +// Check that Base -> Derived conversions are allowed with different cv +// qualifiers. +void test4() +{ + try + { + throw &A::j; + assert(false); + } + catch (der2) + { + } + catch (...) + { + assert(false); + } + + try + { + throw &A::j; + assert(false); + } + catch (der1) + { + } + catch (...) + { + assert(false); + } +} + +// Check that no Derived -> Base conversions are allowed. +void test5() +{ + try + { + throw &B::k; + assert(false); + } + catch (md1) + { + assert(false); + } + catch (md2) + { + assert(false); + } + catch (der1) + { + } + + try + { + throw &B::l; + assert(false); + } + catch (md1) + { + assert(false); + } + catch (md2) + { + assert(false); + } + catch (der2) + { } } @@ -54,4 +170,7 @@ int main() { test1(); test2(); + test3(); + test4(); + test5(); } |