Files
llvm-project/libcxxabi/test/uncaught_exceptions.pass.cpp
Asiri Rathnayake 57e446dafa [libcxxabi] Introduce a -fno-exceptions libc++abi libary variant
Currently there is only support for a -fno-exceptions libc++ build. This is
problematic for functions such as std::terminate() which are defined in
libc++abi and using any of those functions throws away most of the benefits
of using -fno-exceptions (code-size). This patch introduces a -fno-exceptions
libc++abi build to address this issue.

This new variant of libc++abi cannot be linked against any with-exceptions
code as some symbols necessary for handling exceptions are missing in this
library.

Differential revision: http://reviews.llvm.org/D20677

Reviewers: EricWF, mclow.lists, bcraig
llvm-svn: 271267
2016-05-31 12:01:32 +00:00

39 lines
987 B
C++

//===------------------- uncaught_exceptions.pass.cpp ---------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcxxabi-no-exceptions
#include <cxxabi.h>
#include <exception>
#include <cassert>
// namespace __cxxabiv1 {
// extern bool __cxa_uncaught_exception () throw();
// extern unsigned int __cxa_uncaught_exceptions() throw();
// }
struct A {
~A() { assert( __cxxabiv1::__cxa_uncaught_exception()); }
};
struct B {
B(int cnt) : data_(cnt) {}
~B() { assert( data_ == __cxxabiv1::__cxa_uncaught_exceptions()); }
int data_;
};
int main ()
{
try { A a; throw 3; assert (false); }
catch (int) {}
try { B b(1); throw 3; assert (false); }
catch (int) {}
}