blob: fe7374d02bc64da4f483381b042c0b104cfb47c7 [file] [log] [blame]
Marshall Clow5013d7c2015-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
Asiri Rathnayake4174e8b2016-05-31 12:01:32 +000010// UNSUPPORTED: libcxxabi-no-exceptions
11
Marshall Clow5013d7c2015-06-02 13:03:17 +000012#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
21struct A {
22 ~A() { assert( __cxxabiv1::__cxa_uncaught_exception()); }
23 };
24
25struct B {
Eric Fiselierf0c4e602016-12-11 05:43:20 +000026 B(unsigned cnt) : data_(cnt) {}
Marshall Clow5013d7c2015-06-02 13:03:17 +000027 ~B() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); }
Eric Fiselierf0c4e602016-12-11 05:43:20 +000028 unsigned data_;
Marshall Clow5013d7c2015-06-02 13:03:17 +000029 };
30
31int 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}