[cfe-commits] [libcxxabi] r149534 - in /libcxxabi/trunk: src/private_typeinfo.cpp test/catch_member_data_pointer_01.cpp test/catch_member_function_pointer_01.cpp

Howard Hinnant hhinnant at apple.com
Wed Feb 1 12:53:21 PST 2012


Author: hhinnant
Date: Wed Feb  1 14:53:21 2012
New Revision: 149534

URL: http://llvm.org/viewvc/llvm-project?rev=149534&view=rev
Log:
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.

Added:
    libcxxabi/trunk/test/catch_member_data_pointer_01.cpp
    libcxxabi/trunk/test/catch_member_function_pointer_01.cpp
Modified:
    libcxxabi/trunk/src/private_typeinfo.cpp

Modified: libcxxabi/trunk/src/private_typeinfo.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=149534&r1=149533&r2=149534&view=diff
==============================================================================
--- libcxxabi/trunk/src/private_typeinfo.cpp (original)
+++ libcxxabi/trunk/src/private_typeinfo.cpp Wed Feb  1 14:53:21 2012
@@ -380,8 +380,7 @@
     }
 }
 
-// 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

Added: libcxxabi/trunk/test/catch_member_data_pointer_01.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_member_data_pointer_01.cpp?rev=149534&view=auto
==============================================================================
--- libcxxabi/trunk/test/catch_member_data_pointer_01.cpp (added)
+++ libcxxabi/trunk/test/catch_member_data_pointer_01.cpp Wed Feb  1 14:53:21 2012
@@ -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 <cassert>
+
+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();
+}

Added: libcxxabi/trunk/test/catch_member_function_pointer_01.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_member_function_pointer_01.cpp?rev=149534&view=auto
==============================================================================
--- libcxxabi/trunk/test/catch_member_function_pointer_01.cpp (added)
+++ libcxxabi/trunk/test/catch_member_function_pointer_01.cpp Wed Feb  1 14:53:21 2012
@@ -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 <cassert>
+
+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();
+}





More information about the cfe-commits mailing list