1 //===----------------------------------------------------------------------===// 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 10 // UNSUPPORTED: libcpp-no-exceptions 11 // test uncaught_exception 12 13 #include <exception> 14 #include <cassert> 15 16 struct A 17 { ~AA18 ~A() 19 { 20 assert(std::uncaught_exception()); 21 } 22 }; 23 24 struct B 25 { BB26 B() 27 { 28 // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475 29 assert(!std::uncaught_exception()); 30 } 31 }; 32 main()33int main() 34 { 35 try 36 { 37 A a; 38 assert(!std::uncaught_exception()); 39 throw B(); 40 } 41 catch (...) 42 { 43 assert(!std::uncaught_exception()); 44 } 45 assert(!std::uncaught_exception()); 46 } 47