Home | History | Annotate | Download | only in jni
      1 // Test that terminate gets run when a catch filter fails to match while
      2 // running destructors.  Original bug depended on a::~a being inlined.
      3 // { dg-do run }
      4 // { dg-options -O }
      5 
      6 #include <exception>
      7 #include <cstdlib>
      8 
      9 struct e1 {};
     10 struct e2 {};
     11 
     12 struct a
     13 {
     14   a () { }
     15 
     16   ~a ()
     17     {
     18       try
     19 	{
     20 	  throw e1();
     21 	}
     22       catch (e2 &)
     23 	{
     24         }
     25     }
     26 };
     27 
     28 void
     29 ex_test ()
     30 {
     31   a aa;
     32   try
     33     {
     34       throw e1 ();
     35     }
     36   catch (e2 &)
     37     {
     38     }
     39 }
     40 
     41 void my_terminate ()
     42 {
     43   std::exit (0);
     44 }
     45 
     46 int
     47 main ()
     48 {
     49   std::set_terminate (my_terminate);
     50 
     51   try
     52     {
     53       ex_test ();
     54     }
     55   catch (...)
     56     {
     57     }
     58   abort ();
     59 }
     60