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