[libcxxabi] r236864 - Add tests missed in r236862

Tom Stellard thomas.stellard at amd.com
Fri May 8 08:26:18 PDT 2015


Author: tstellar
Date: Fri May  8 10:26:17 2015
New Revision: 236864

URL: http://llvm.org/viewvc/llvm-project?rev=236864&view=rev
Log:
Add tests missed in r236862

Modified:
    libcxxabi/branches/release_36/test/catch_member_data_pointer_01.cpp
    libcxxabi/branches/release_36/test/catch_pointer_nullptr.cpp

Modified: libcxxabi/branches/release_36/test/catch_member_data_pointer_01.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_36/test/catch_member_data_pointer_01.cpp?rev=236864&r1=236863&r2=236864&view=diff
==============================================================================
--- libcxxabi/branches/release_36/test/catch_member_data_pointer_01.cpp (original)
+++ libcxxabi/branches/release_36/test/catch_member_data_pointer_01.cpp Fri May  8 10:26:17 2015
@@ -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,11 +43,114 @@ 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)
@@ -47,6 +159,10 @@ void test2()
     }
     catch (md2)
     {
+        assert(false);
+    }
+    catch (der2)
+    {
     }
 }
 
@@ -54,4 +170,7 @@ int main()
 {
     test1();
     test2();
+    test3();
+    test4();
+    test5();
 }

Modified: libcxxabi/branches/release_36/test/catch_pointer_nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_36/test/catch_pointer_nullptr.cpp?rev=236864&r1=236863&r2=236864&view=diff
==============================================================================
--- libcxxabi/branches/release_36/test/catch_pointer_nullptr.cpp (original)
+++ libcxxabi/branches/release_36/test/catch_pointer_nullptr.cpp Fri May  8 10:26:17 2015
@@ -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::**>();
 }





More information about the cfe-commits mailing list