]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/libsupc++/exception
prefetch-3.c: Allow x86_64, but require ilp32.
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / exception
CommitLineData
6305f20a 1// Exception Handling support header for -*- C++ -*-
d34786e3 2
3cbc7af0 3// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2005
d66ae36a 4// Free Software Foundation
e2c09482 5//
cbecceb9 6// This file is part of GCC.
6305f20a 7//
cbecceb9 8// GCC is free software; you can redistribute it and/or modify
6305f20a
BK
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2, or (at your option)
11// any later version.
12//
cbecceb9 13// GCC is distributed in the hope that it will be useful,
6305f20a
BK
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
cbecceb9 19// along with GCC; see the file COPYING. If not, write to
83f51799
KC
20// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21// Boston, MA 02110-1301, USA.
6305f20a
BK
22
23// As a special exception, you may use this file as part of a free software
24// library without restriction. Specifically, if other files instantiate
25// templates or use macros or inline functions from this file, or you compile
26// this file and link it with other files to produce an executable, this
27// file does not by itself cause the resulting executable to be covered by
28// the GNU General Public License. This exception does not however
29// invalidate any other reasons why the executable file might be covered by
30// the GNU General Public License.
31
669f7a03
PE
32/** @file exception
33 * This header defines several types and functions relating to the
34 * handling of exceptions in a C++ program.
35 */
36
6305f20a
BK
37#ifndef __EXCEPTION__
38#define __EXCEPTION__
39
723acbd5
MM
40#pragma GCC visibility push(default)
41
3cbc7af0
BK
42#include <bits/c++config.h>
43
6305f20a
BK
44extern "C++" {
45
d34786e3
BK
46namespace std
47{
aa2d5ba2
PE
48 /**
49 * @brief Base class for all library exceptions.
50 *
51 * This is the base class for all exceptions thrown by the standard
669f7a03
PE
52 * library, and by certain language expressions. You are free to derive
53 * your own %exception classes, or use a different hierarchy, or to
54 * throw non-class data (e.g., fundamental types).
669f7a03 55 */
d34786e3
BK
56 class exception
57 {
58 public:
59 exception() throw() { }
f68147f7 60 virtual ~exception() throw();
669f7a03
PE
61 /** Returns a C-style character string describing the general cause
62 * of the current error. */
d34786e3
BK
63 virtual const char* what() const throw();
64 };
6305f20a 65
669f7a03
PE
66 /** If an %exception is thrown which is not listed in a function's
67 * %exception specification, one of these may be thrown. */
d34786e3
BK
68 class bad_exception : public exception
69 {
70 public:
71 bad_exception() throw() { }
e05cd3dd
PC
72 // This declaration is not useless:
73 // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
d66ae36a 74 virtual ~bad_exception() throw();
d34786e3 75 };
6305f20a 76
669f7a03 77 /// If you write a replacement %terminate handler, it must be of this type.
d34786e3 78 typedef void (*terminate_handler) ();
669f7a03 79 /// If you write a replacement %unexpected handler, it must be of this type.
d34786e3 80 typedef void (*unexpected_handler) ();
6305f20a 81
669f7a03 82 /// Takes a new handler function as an argument, returns the old function.
d34786e3 83 terminate_handler set_terminate(terminate_handler) throw();
669f7a03 84 /** The runtime will call this function if %exception handling must be
bad38757 85 * abandoned for any reason. It can also be called by the user. */
d34786e3 86 void terminate() __attribute__ ((__noreturn__));
6305f20a 87
669f7a03 88 /// Takes a new handler function as an argument, returns the old function.
d34786e3 89 unexpected_handler set_unexpected(unexpected_handler) throw();
669f7a03
PE
90 /** The runtime will call this function if an %exception is thrown which
91 * violates the function's %exception specification. */
d34786e3 92 void unexpected() __attribute__ ((__noreturn__));
6305f20a 93
669f7a03
PE
94 /** [18.6.4]/1: "Returns true after completing evaluation of a
95 * throw-expression until either completing initialization of the
96 * exception-declaration in the matching handler or entering @c unexpected()
97 * due to the throw; or after entering @c terminate() for any reason
98 * other than an explicit call to @c terminate(). [Note: This includes
99 * stack unwinding [15.2]. end note]"
100 *
101 * 2: "When @c uncaught_exception() is true, throwing an %exception can
102 * result in a call of @c terminate() (15.5.1)."
103 */
d34786e3 104 bool uncaught_exception() throw();
6305f20a
BK
105} // namespace std
106
3cbc7af0
BK
107_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
108
74a3070f 109 /** A replacement for the standard terminate_handler which prints more
ffe94f83
PE
110 information about the terminating exception (if any) on stderr. Call
111 @code
afb0141f 112 std::set_terminate (__gnu_cxx::__verbose_terminate_handler)
ffe94f83 113 @endcode
efe44c60
PE
114 to use. For more info, see
115 http://gcc.gnu.org/onlinedocs/libstdc++/19_diagnostics/howto.html#4
bad38757
PE
116
117 In 3.4 and later, this is on by default.
efe44c60 118 */
afb0141f 119 void __verbose_terminate_handler ();
3cbc7af0
BK
120
121_GLIBCXX_END_NAMESPACE
74a3070f 122
6305f20a
BK
123} // extern "C++"
124
723acbd5
MM
125#pragma GCC visibility pop
126
6305f20a 127#endif