Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / language.support / support.exception / uncaught / uncaught_exceptions.pass.cpp
blob40aad7103a4b640ad75ad8b4027a370e6cfb80c5
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-exceptions
11 // std::uncaught_exceptions() gives the wrong answer in versions of
12 // the dylib that don't contain 3a92ecc. Previously, it only returned
13 // 0 or 1.
14 // XFAIL: using-built-library-before-llvm-9
16 // test uncaught_exceptions
18 #include <exception>
19 #include <cassert>
21 #include "test_macros.h"
23 struct Uncaught {
24 Uncaught(int depth) : d_(depth) {}
25 ~Uncaught() { assert(std::uncaught_exceptions() == d_); }
26 int d_;
29 struct Outer {
30 Outer(int depth) : d_(depth) {}
31 ~Outer() {
32 try {
33 assert(std::uncaught_exceptions() == d_);
34 Uncaught u(d_+1);
35 throw 2;
37 catch (int) {}
39 int d_;
42 int main(int, char**) {
43 assert(std::uncaught_exceptions() == 0);
45 Outer o(0);
48 assert(std::uncaught_exceptions() == 0);
50 try {
51 Outer o(1);
52 throw 1;
54 catch (int) {
55 assert(std::uncaught_exceptions() == 0);
58 assert(std::uncaught_exceptions() == 0);
60 return 0;