77 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: no-exceptions10 11#include <cassert>12 13#if __has_feature(cxx_nullptr)14 15struct A16{17 const int i;18 int j;19};20 21typedef const int A::*md1;22typedef int A::*md2;23 24void test1()25{26 try27 {28 throw nullptr;29 assert(false);30 }31 catch (md2 p)32 {33 assert(!p);34 }35 catch (md1)36 {37 assert(false);38 }39}40 41void test2()42{43 try44 {45 throw nullptr;46 assert(false);47 }48 catch (md1 p)49 {50 assert(!p);51 }52 catch (md2)53 {54 assert(false);55 }56}57 58#else59 60void test1()61{62}63 64void test2()65{66}67 68#endif69 70int main(int, char**)71{72 test1();73 test2();74 75 return 0;76}77