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