blob: fd4b8f416460096d0152138676bcc66cdf73c74e [file] [log] [blame]
Marshall Clow604de5c2015-06-02 13:03:17 +00001//===------------------- 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
19struct A {
20 ~A() { assert( __cxxabiv1::__cxa_uncaught_exception()); }
21 };
22
23struct B {
24 B(int cnt) : data_(cnt) {}
25 ~B() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); }
26 int data_;
27 };
28
29int 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}