• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // UNSUPPORTED: libcxxabi-no-exceptions
11 
12 #include <cxxabi.h>
13 #include <exception>
14 #include <cassert>
15 
16 // namespace __cxxabiv1 {
17 //      extern bool          __cxa_uncaught_exception () throw();
18 //      extern unsigned int  __cxa_uncaught_exceptions() throw();
19 // }
20 
21 struct A {
~AA22     ~A() { assert( __cxxabiv1::__cxa_uncaught_exception()); }
23     };
24 
25 struct B {
BB26     B(unsigned cnt) : data_(cnt) {}
~BB27     ~B() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); }
28     unsigned data_;
29     };
30 
main()31 int main ()
32 {
33     try { A a; throw 3; assert (false); }
34     catch (int) {}
35 
36     try { B b(1); throw 3; assert (false); }
37     catch (int) {}
38 }
39