mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00
Fix embarrasing typo in uncaught_exceptions. Update tests to really test this. Thanks to Peter Klotz for calling my attention to this.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@333467 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -18,7 +18,7 @@ bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
|
|||||||
|
|
||||||
int uncaught_exceptions() _NOEXCEPT
|
int uncaught_exceptions() _NOEXCEPT
|
||||||
{
|
{
|
||||||
# if _LIBCPPABI_VERSION > 1101
|
# if _LIBCPPABI_VERSION > 1001
|
||||||
return __cxa_uncaught_exceptions();
|
return __cxa_uncaught_exceptions();
|
||||||
# else
|
# else
|
||||||
return __cxa_uncaught_exception() ? 1 : 0;
|
return __cxa_uncaught_exception() ? 1 : 0;
|
||||||
|
@@ -15,40 +15,48 @@
|
|||||||
// XFAIL: availability=macosx10.9
|
// XFAIL: availability=macosx10.9
|
||||||
// XFAIL: availability=macosx10.10
|
// XFAIL: availability=macosx10.10
|
||||||
// XFAIL: availability=macosx10.11
|
// XFAIL: availability=macosx10.11
|
||||||
|
// XFAIL: with_system_cxx_lib=macosx10.12
|
||||||
|
// XFAIL: with_system_cxx_lib=macosx10.13
|
||||||
|
|
||||||
// test uncaught_exceptions
|
// test uncaught_exceptions
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
struct A
|
struct Uncaught {
|
||||||
{
|
Uncaught(int depth) : d_(depth) {}
|
||||||
~A()
|
~Uncaught() { assert(std::uncaught_exceptions() == d_); }
|
||||||
{
|
int d_;
|
||||||
assert(std::uncaught_exceptions() > 0);
|
};
|
||||||
|
|
||||||
|
struct Outer {
|
||||||
|
Outer(int depth) : d_(depth) {}
|
||||||
|
~Outer() {
|
||||||
|
try {
|
||||||
|
assert(std::uncaught_exceptions() == d_);
|
||||||
|
Uncaught u(d_+1);
|
||||||
|
throw 2;
|
||||||
}
|
}
|
||||||
|
catch (int) {}
|
||||||
|
}
|
||||||
|
int d_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct B
|
int main () {
|
||||||
{
|
assert(std::uncaught_exceptions() == 0);
|
||||||
B()
|
|
||||||
{
|
{
|
||||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
|
Outer o(0);
|
||||||
assert(std::uncaught_exceptions() == 0);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
assert(std::uncaught_exceptions() == 0);
|
||||||
int main()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
A a;
|
try {
|
||||||
|
Outer o(1);
|
||||||
|
throw 1;
|
||||||
|
}
|
||||||
|
catch (int) {
|
||||||
assert(std::uncaught_exceptions() == 0);
|
assert(std::uncaught_exceptions() == 0);
|
||||||
throw B();
|
}
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
assert(std::uncaught_exception() == 0);
|
|
||||||
}
|
}
|
||||||
assert(std::uncaught_exceptions() == 0);
|
assert(std::uncaught_exceptions() == 0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user