blob: 1adc904fd5d2d879d474046a768f18665540b5f9 [file] [log] [blame]
Marshall Clow8731c5d2015-06-02 15:33:38 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Marshall Clow8731c5d2015-06-02 15:33:38 +000010// test uncaught_exceptions
11
12#include <exception>
13#include <cassert>
14
15struct A
16{
17 ~A()
18 {
19 assert(std::uncaught_exceptions() > 0);
20 }
21};
22
23struct B
24{
25 B()
26 {
27 // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
28 assert(std::uncaught_exceptions() == 0);
29 }
30};
31
32int main()
33{
34 try
35 {
36 A a;
37 assert(std::uncaught_exceptions() == 0);
38 throw B();
39 }
40 catch (...)
41 {
42 assert(std::uncaught_exception() == 0);
43 }
44 assert(std::uncaught_exceptions() == 0);
45}