Home | History | Annotate | Download | only in test
      1 //===------------------- uncaught_exceptions.pass.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 <cxxabi.h>
     11 #include <exception>
     12 #include <cassert>
     13 
     14 // namespace __cxxabiv1 {
     15 //      extern bool          __cxa_uncaught_exception () throw();
     16 //      extern unsigned int  __cxa_uncaught_exceptions() throw();
     17 // }
     18 
     19 struct A {
     20     ~A() { assert( __cxxabiv1::__cxa_uncaught_exception()); }
     21     };
     22 
     23 struct B {
     24     B(int cnt) : data_(cnt) {}
     25     ~B() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); }
     26     int data_;
     27     };
     28 
     29 int main ()
     30 {
     31     try { A a; throw 3; assert (false); }
     32     catch (int) {}
     33 
     34     try { B b(1); throw 3; assert (false); }
     35     catch (int) {}
     36 }
     37