1 //===----------------- catch_member_pointer_nullptr.cpp -------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: libcxxabi-no-exceptions 11 12 #include <cassert> 13 14 #if __has_feature(cxx_nullptr) 15 16 struct A 17 { 18 const int i; 19 int j; 20 }; 21 22 typedef const int A::*md1; 23 typedef int A::*md2; 24 25 void test1() 26 { 27 try 28 { 29 throw nullptr; 30 assert(false); 31 } 32 catch (md2 p) 33 { 34 assert(!p); 35 } 36 catch (md1) 37 { 38 assert(false); 39 } 40 } 41 42 void test2() 43 { 44 try 45 { 46 throw nullptr; 47 assert(false); 48 } 49 catch (md1 p) 50 { 51 assert(!p); 52 } 53 catch (md2) 54 { 55 assert(false); 56 } 57 } 58 59 #else 60 61 void test1() 62 { 63 } 64 65 void test2() 66 { 67 } 68 69 #endif 70 71 int main() 72 { 73 test1(); 74 test2(); 75 } 76