]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/exception_ptr/lifespan.cc
1 // { dg-options "-std=gnu++0x" }
2 // 2008-05-25 Sebastian Redl <sebastian.redl@getdesigned.at>
4 // Copyright (C) 2008 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 // Tests the life span of the exception object.
25 #include <testsuite_hooks.h>
27 bool may_destruct
= false;
34 destructing() : copied(false) { }
35 destructing(const destructing
&o
) : copied(false) { o
.copied
= true; }
36 ~destructing() { VERIFY( copied
|| may_destruct
); }
41 bool test
__attribute__((unused
)) = true;
46 // Test the destructing class.
48 destructing
*d
= new destructing
;
58 bool test
__attribute__((unused
)) = true;
73 bool test
__attribute__((unused
)) = true;
82 exception_ptr ep
= current_exception();
91 bool test
__attribute__((unused
)) = true;
101 ep
= current_exception();
105 may_destruct
= false;
114 exception_ptr ep
= current_exception();
115 rethrow_exception(ep
);
121 bool test
__attribute__((unused
)) = true;
124 may_destruct
= false;
131 may_destruct
= false;
140 exception_ptr ep
= current_exception();
147 bool test
__attribute__((unused
)) = true;
150 may_destruct
= false;
157 may_destruct
= false;
160 std::exception_ptr gep
;
164 bool test
__attribute__((unused
)) = true;
167 may_destruct
= false;
172 gep
= current_exception();