From 2d6810fbd68d2aad2430885c8a4ee69814dd031d Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 1 Feb 2012 20:53:21 +0000 Subject: Quash a TODO related to catching pointer-to-member. These tests fail on my copy of gcc-4.2. But I believe the tests to be correct (and they pass for libc++abi). I've enquired on the C++ standards mailing list for a clarification in case I'm wrong. So far I've gotten one response that agrees with me. llvm-svn: 149534 --- libcxxabi/src/private_typeinfo.cpp | 3 +- libcxxabi/test/catch_member_data_pointer_01.cpp | 57 ++++++++++++++++++++++ .../test/catch_member_function_pointer_01.cpp | 57 ++++++++++++++++++++++ 3 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 libcxxabi/test/catch_member_data_pointer_01.cpp create mode 100644 libcxxabi/test/catch_member_function_pointer_01.cpp (limited to 'libcxxabi') diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp index e6ffff106bf..13fbd32352f 100644 --- a/libcxxabi/src/private_typeinfo.cpp +++ b/libcxxabi/src/private_typeinfo.cpp @@ -380,8 +380,7 @@ __vmi_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info, } } -// Handles bullets 1 and 4 -// TODO: Are we good to go here for __pointer_to_member_type_info? +// Handles bullets 1 and 4 for both pointers and member pointers bool __pbase_type_info::can_catch(const __shim_type_info* thrown_type, void*&) const diff --git a/libcxxabi/test/catch_member_data_pointer_01.cpp b/libcxxabi/test/catch_member_data_pointer_01.cpp new file mode 100644 index 00000000000..44ff7536a03 --- /dev/null +++ b/libcxxabi/test/catch_member_data_pointer_01.cpp @@ -0,0 +1,57 @@ +//===----------------- catch_member_data_pointer_01.cpp -------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include + +struct A +{ + const int i; + int j; +}; + +typedef const int A::*md1; +typedef int A::*md2; + +void test1() +{ + try + { + throw &A::i; + assert(false); + } + catch (md2) + { + assert(false); + } + catch (md1) + { + } +} + +void test2() +{ + try + { + throw &A::j; + assert(false); + } + catch (md1) + { + assert(false); + } + catch (md2) + { + } +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxxabi/test/catch_member_function_pointer_01.cpp b/libcxxabi/test/catch_member_function_pointer_01.cpp new file mode 100644 index 00000000000..4503d889c17 --- /dev/null +++ b/libcxxabi/test/catch_member_function_pointer_01.cpp @@ -0,0 +1,57 @@ +//===--------------- catch_member_function_pointer_01.cpp -----------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include + +struct A +{ + void foo() {} + void bar() const {} +}; + +typedef void (A::*mf1)(); +typedef void (A::*mf2)() const; + +void test1() +{ + try + { + throw &A::foo; + assert(false); + } + catch (mf2) + { + assert(false); + } + catch (mf1) + { + } +} + +void test2() +{ + try + { + throw &A::bar; + assert(false); + } + catch (mf1) + { + assert(false); + } + catch (mf2) + { + } +} + +int main() +{ + test1(); + test2(); +} -- cgit v1.2.3