1*eb8650a7SLouis Dionne //===----------------------------------------------------------------------===// 2e434b34fSJonathan Roelofs // 357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e434b34fSJonathan Roelofs // 7e434b34fSJonathan Roelofs //===----------------------------------------------------------------------===// 8e434b34fSJonathan Roelofs 960ba1fefSLouis Dionne // Catching an exception thrown as nullptr was not properly handled before 1060ba1fefSLouis Dionne // 2f984cab4fa7, which landed in macOS 10.13 11c360553cSLouis Dionne // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}} 1260ba1fefSLouis Dionne 138c61114cSLouis Dionne // UNSUPPORTED: no-exceptions 1457e446daSAsiri Rathnayake 15e434b34fSJonathan Roelofs #include <cassert> 16e434b34fSJonathan Roelofs 17e434b34fSJonathan Roelofs #if __has_feature(cxx_nullptr) 18e434b34fSJonathan Roelofs 19e434b34fSJonathan Roelofs struct A 20e434b34fSJonathan Roelofs { 21e434b34fSJonathan Roelofs const int i; 22e434b34fSJonathan Roelofs int j; 23e434b34fSJonathan Roelofs }; 24e434b34fSJonathan Roelofs 25e434b34fSJonathan Roelofs typedef const int A::*md1; 26e434b34fSJonathan Roelofs typedef int A::*md2; 27e434b34fSJonathan Roelofs test1()28e434b34fSJonathan Roelofsvoid test1() 29e434b34fSJonathan Roelofs { 30e434b34fSJonathan Roelofs try 31e434b34fSJonathan Roelofs { 32e434b34fSJonathan Roelofs throw nullptr; 33e434b34fSJonathan Roelofs assert(false); 34e434b34fSJonathan Roelofs } 352f984cabSRichard Smith catch (md2 p) 36e434b34fSJonathan Roelofs { 372f984cabSRichard Smith assert(!p); 38e434b34fSJonathan Roelofs } 39e434b34fSJonathan Roelofs catch (md1) 40e434b34fSJonathan Roelofs { 41e434b34fSJonathan Roelofs assert(false); 42e434b34fSJonathan Roelofs } 43e434b34fSJonathan Roelofs } 44e434b34fSJonathan Roelofs test2()45e434b34fSJonathan Roelofsvoid test2() 46e434b34fSJonathan Roelofs { 47e434b34fSJonathan Roelofs try 48e434b34fSJonathan Roelofs { 49e434b34fSJonathan Roelofs throw nullptr; 50e434b34fSJonathan Roelofs assert(false); 51e434b34fSJonathan Roelofs } 522f984cabSRichard Smith catch (md1 p) 53e434b34fSJonathan Roelofs { 542f984cabSRichard Smith assert(!p); 55e434b34fSJonathan Roelofs } 56e434b34fSJonathan Roelofs catch (md2) 57e434b34fSJonathan Roelofs { 58e434b34fSJonathan Roelofs assert(false); 59e434b34fSJonathan Roelofs } 60e434b34fSJonathan Roelofs } 61e434b34fSJonathan Roelofs 62e434b34fSJonathan Roelofs #else 63e434b34fSJonathan Roelofs test1()64e434b34fSJonathan Roelofsvoid test1() 65e434b34fSJonathan Roelofs { 66e434b34fSJonathan Roelofs } 67e434b34fSJonathan Roelofs test2()68e434b34fSJonathan Roelofsvoid test2() 69e434b34fSJonathan Roelofs { 70e434b34fSJonathan Roelofs } 71e434b34fSJonathan Roelofs 72e434b34fSJonathan Roelofs #endif 73e434b34fSJonathan Roelofs main(int,char **)74504bc07dSLouis Dionneint main(int, char**) 75e434b34fSJonathan Roelofs { 76e434b34fSJonathan Roelofs test1(); 77e434b34fSJonathan Roelofs test2(); 78504bc07dSLouis Dionne 79504bc07dSLouis Dionne return 0; 80e434b34fSJonathan Roelofs } 81