Home | History | Annotate | Download | only in tests
      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 __cplusplus >= 201103L
     13 
     14 void 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 
     32 void 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 
     50 void test1()
     51 {
     52 }
     53 
     54 void test2()
     55 {
     56 }
     57 
     58 #endif
     59 
     60 int main()
     61 {
     62     test1();
     63     test2();
     64 }
     65