Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / language.support / support.exception / uncaught / uncaught_exception.pass.cpp
blobe368ce177b317714908de94e54023bd875011a13
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
10 // test uncaught_exception
12 #include <exception>
13 #include <cassert>
15 #include "test_macros.h"
17 struct A
19 ~A()
21 assert(std::uncaught_exception());
25 struct B
27 B()
29 // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
30 assert(!std::uncaught_exception());
34 int main(int, char**)
36 try
38 A a;
39 assert(!std::uncaught_exception());
40 throw B();
42 catch (...)
44 assert(!std::uncaught_exception());
46 assert(!std::uncaught_exception());
48 return 0;