1 //===--------------------- catch_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 #include <cassert> 11 12 #if __has_feature(cxx_nullptr) 13 test1()14void test1() 15 { 16 try 17 { 18 throw nullptr; 19 assert(false); 20 } 21 catch (int*) 22 { 23 } 24 catch (long*) 25 { 26 assert(false); 27 } 28 } 29 30 struct A {}; 31 test2()32void test2() 33 { 34 try 35 { 36 throw nullptr; 37 assert(false); 38 } 39 catch (A*) 40 { 41 } 42 catch (int*) 43 { 44 assert(false); 45 } 46 } 47 48 #else 49 test1()50void test1() 51 { 52 } 53 test2()54void test2() 55 { 56 } 57 58 #endif 59 main()60int main() 61 { 62 test1(); 63 test2(); 64 } 65