Debian Codegraph @

libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <ios>
10
11 // template <class charT, class traits> class basic_ios
12
13 // void clear(iostate state);
14
15 // Make sure that we abort() when exceptions are disabled and the exception
16 // flag is set for the iostate we pass to clear().
17
18 // REQUIRES: no-exceptions
19
20 #include <csignal>
21 #include <cstdlib>
22 #include <ios>
23 #include <streambuf>
24
25 #include "test_macros.h"
26
27
28 void exit_success(int) {
29 std::_Exit(EXIT_SUCCESS);
30 }
31
32 struct testbuf : public std::streambuf {};
33
34 int main(int, char**) {
35 std::signal(SIGABRT, exit_success);
36
37 testbuf buf;
38 std::ios ios(&buf);
39 ios.exceptions(std::ios::badbit);
40 ios.clear(std::ios::badbit);
41
42 return EXIT_FAILURE;
43 }