diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2015-06-02 15:33:38 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2015-06-02 15:33:38 +0000 |
commit | 89102f0fa96c1d3b53bf289802167fa78baaa83d (patch) | |
tree | 4def1737c86f0993c7cebf597e0b6cc9e53eacf8 /libcxx/test/std/language.support/support.exception/uncaught | |
parent | 1feab0f95ea0202f95a555a86f5dd60db4a8a5c8 (diff) | |
download | bcm5719-llvm-89102f0fa96c1d3b53bf289802167fa78baaa83d.tar.gz bcm5719-llvm-89102f0fa96c1d3b53bf289802167fa78baaa83d.zip |
Implement uncaught_exceptions() using the newly added hooks in libc++abi, when available
llvm-svn: 238846
Diffstat (limited to 'libcxx/test/std/language.support/support.exception/uncaught')
-rw-r--r-- | libcxx/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libcxx/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp b/libcxx/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp new file mode 100644 index 00000000000..1adc904fd5d --- /dev/null +++ b/libcxx/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// test uncaught_exceptions + +#include <exception> +#include <cassert> + +struct A +{ + ~A() + { + assert(std::uncaught_exceptions() > 0); + } +}; + +struct B +{ + B() + { + // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475 + assert(std::uncaught_exceptions() == 0); + } +}; + +int main() +{ + try + { + A a; + assert(std::uncaught_exceptions() == 0); + throw B(); + } + catch (...) + { + assert(std::uncaught_exception() == 0); + } + assert(std::uncaught_exceptions() == 0); +} |