1 //===--------------------- catch_const_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 void test1() 19 { 20 try 21 { 22 throw nullptr; 23 assert(false); 24 } 25 catch (A*) 26 { 27 } 28 catch (const A*) 29 { 30 assert(false); 31 } 32 } 33 34 35 void test2() 36 { 37 try 38 { 39 throw nullptr; 40 assert(false); 41 } 42 catch (const A*) 43 { 44 } 45 catch (A*) 46 { 47 assert(false); 48 } 49 } 50 51 void test3() 52 { 53 try 54 { 55 throw nullptr; 56 assert(false); 57 } 58 catch (const A* const) 59 { 60 } 61 catch (A*) 62 { 63 assert(false); 64 } 65 } 66 67 void test4() 68 { 69 try 70 { 71 throw nullptr; 72 assert(false); 73 } 74 catch (A*) 75 { 76 } 77 catch (const A* const) 78 { 79 assert(false); 80 } 81 } 82 83 void test5() 84 { 85 try 86 { 87 throw nullptr; 88 assert(false); 89 } 90 catch (A const*) 91 { 92 } 93 catch (A*) 94 { 95 assert(false); 96 } 97 } 98 99 void test6() 100 { 101 try 102 { 103 throw nullptr; 104 assert(false); 105 } 106 catch (A*) 107 { 108 } 109 catch (A const*) 110 { 111 assert(false); 112 } 113 } 114 115 116 #else 117 118 void test1() {} 119 void test2() {} 120 void test3() {} 121 void test4() {} 122 void test5() {} 123 void test6() {} 124 125 #endif 126 127 int main() 128 { 129 test1(); 130 test2(); 131 test3(); 132 test4(); 133 test5(); 134 test6(); 135 } 136