• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // UNSUPPORTED: libcpp-has-no-threads
12 // UNSUPPORTED: c++98, c++03
13 
14 // MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
15 // MODULES_DEFINES: _LIBCPP_DEBUG=0
16 
17 // Can't test the system lib because this test enables debug mode
18 // UNSUPPORTED: with_system_cxx_lib
19 
20 // <future>
21 
22 // class promise<R>
23 
24 // void set_exception(exception_ptr p);
25 // Test that a null exception_ptr is diagnosed.
26 
27 #define _LIBCPP_DEBUG 0
28 #define _LIBCPP_DEBUG_USE_EXCEPTIONS
29 #include <future>
30 #include <exception>
31 #include <cstdlib>
32 #include <cassert>
33 
34 
main()35 int main()
36 {
37     typedef std::__libcpp_debug_exception ExType;
38     {
39         typedef int T;
40         std::promise<T> p;
41         try {
42             p.set_exception(std::exception_ptr());
43             assert(false);
44         } catch (ExType const&) {
45         }
46     }
47     {
48         typedef int& T;
49         std::promise<T> p;
50         try {
51             p.set_exception(std::exception_ptr());
52             assert(false);
53         } catch (ExType const&) {
54         }
55     }
56 }
57