]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc
1 // Copyright (C) 2015-2016 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-std=gnu++1z" }
22 #include <testsuite_hooks.h>
24 #ifndef __cpp_lib_uncaught_exceptions
25 # error "Feature-test macro for uncaught_exceptions missing"
26 #elif __cpp_lib_uncaught_exceptions != 201411
27 # error "Feature-test macro for uncaught_exceptions has wrong value"
30 struct UncaughtVerifier
32 int expected_count_
= 0;
33 UncaughtVerifier(int expected_count
) : expected_count_(expected_count
) {}
36 VERIFY(std::uncaught_exceptions() == expected_count_
);
44 Transaction(bool& result
)
45 : initial_count_(std::uncaught_exceptions()),
49 if (std::uncaught_exceptions() != initial_count_
) {
58 UncaughtVerifier uv
{0};
60 UncaughtVerifier uv
{0};
67 UncaughtVerifier uv
{1};
70 UncaughtVerifier uv
{0};
79 UncaughtVerifier uv_
{1};
80 ~Wrap() {try {UncaughtVerifier uv2
{2}; throw 0;} catch(...) {}}
85 UncaughtVerifier uv
{0};
93 Transaction t
{result
};
103 Transaction t
{result
};
118 Wrap(bool& result
) : result_(result
) {}
121 Transaction t
{result_
};
124 Transaction t
{result
};
141 Wrap(bool& result
) : result_(result
) {}
145 Transaction t
{result_
};
150 Transaction t
{result
};