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 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 30struct A {}; 31 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 50void test1() 51{ 52} 53 54void test2() 55{ 56} 57 58#endif 59 60int main() 61{ 62 test1(); 63 test2(); 64} 65