Home | History | Annotate | Download | only in test
      1 //===----------------- catch_member_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 
     14 struct A
     15 {
     16     const int i;
     17     int j;
     18 };
     19 
     20 typedef const int A::*md1;
     21 typedef       int A::*md2;
     22 
     23 void test1()
     24 {
     25     try
     26     {
     27         throw nullptr;
     28         assert(false);
     29     }
     30     catch (md2)
     31     {
     32     }
     33     catch (md1)
     34     {
     35         assert(false);
     36     }
     37 }
     38 
     39 void test2()
     40 {
     41     try
     42     {
     43         throw nullptr;
     44         assert(false);
     45     }
     46     catch (md1)
     47     {
     48     }
     49     catch (md2)
     50     {
     51         assert(false);
     52     }
     53 }
     54 
     55 #else
     56 
     57 void test1()
     58 {
     59 }
     60 
     61 void test2()
     62 {
     63 }
     64 
     65 #endif
     66 
     67 int main()
     68 {
     69     test1();
     70     test2();
     71 }
     72