Home | History | Annotate | Download | only in tests
      1 //===------------------------- catch_ptr_02.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 struct  A {};
     13 A a;
     14 const A ca = A();
     15 
     16 void test1 ()
     17 {
     18     try
     19     {
     20         throw &a;
     21         assert(false);
     22     }
     23     catch ( const A* )
     24     {
     25     }
     26     catch ( A *)
     27     {
     28         assert (false);
     29     }
     30 }
     31 
     32 void test2 ()
     33 {
     34     try
     35      {
     36     	throw &a;
     37         assert(false);
     38     }
     39     catch ( A* )
     40     {
     41     }
     42     catch ( const A *)
     43     {
     44          assert (false);
     45     }
     46 }
     47 
     48 void test3 ()
     49 {
     50     try
     51     {
     52         throw &ca;
     53         assert(false);
     54     }
     55     catch ( const A* )
     56     {
     57     }
     58     catch ( A *)
     59     {
     60         assert (false);
     61     }
     62 }
     63 
     64 void test4 ()
     65 {
     66     try
     67     {
     68         throw &ca;
     69         assert(false);
     70     }
     71     catch ( A *)
     72     {
     73         assert (false);
     74     }
     75     catch ( const A* )
     76     {
     77     }
     78 }
     79 
     80 int main()
     81 {
     82     test1();
     83     test2();
     84     test3();
     85     test4();
     86 }
     87