]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/libsupc++/exception
* gcc.dg/asm-fs-1.c: Disable warnings when compiling.
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / exception
CommitLineData
6305f20a 1// Exception Handling support header for -*- C++ -*-
d34786e3 2
d66ae36a
PC
3// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002
4// Free Software Foundation
e2c09482 5//
6305f20a
BK
6// This file is part of GNU CC.
7//
8// GNU CC is free software; you can redistribute it and/or modify
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//
13// GNU CC is distributed in the hope that it will be useful,
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
19// along with GNU CC; see the file COPYING. If not, write to
20// the Free Software Foundation, 59 Temple Place - Suite 330,
21// Boston, MA 02111-1307, USA.
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
6305f20a
BK
40extern "C++" {
41
d34786e3
BK
42namespace std
43{
669f7a03
PE
44 /** This is the base class for all exceptions thrown by the standard
45 * library, and by certain language expressions. You are free to derive
46 * your own %exception classes, or use a different hierarchy, or to
47 * throw non-class data (e.g., fundamental types).
48 * @brief Base class for all library exceptions.
49 */
d34786e3
BK
50 class exception
51 {
52 public:
53 exception() throw() { }
f68147f7 54 virtual ~exception() throw();
669f7a03
PE
55 /** Returns a C-style character string describing the general cause
56 * of the current error. */
d34786e3
BK
57 virtual const char* what() const throw();
58 };
6305f20a 59
669f7a03
PE
60 /** If an %exception is thrown which is not listed in a function's
61 * %exception specification, one of these may be thrown. */
d34786e3
BK
62 class bad_exception : public exception
63 {
64 public:
65 bad_exception() throw() { }
d66ae36a 66 virtual ~bad_exception() throw();
d34786e3 67 };
6305f20a 68
669f7a03 69 /// If you write a replacement %terminate handler, it must be of this type.
d34786e3 70 typedef void (*terminate_handler) ();
669f7a03 71 /// If you write a replacement %unexpected handler, it must be of this type.
d34786e3 72 typedef void (*unexpected_handler) ();
6305f20a 73
669f7a03 74 /// Takes a new handler function as an argument, returns the old function.
d34786e3 75 terminate_handler set_terminate(terminate_handler) throw();
669f7a03
PE
76 /** The runtime will call this function if %exception handling must be
77 * abandoned for any reason. */
d34786e3 78 void terminate() __attribute__ ((__noreturn__));
6305f20a 79
669f7a03 80 /// Takes a new handler function as an argument, returns the old function.
d34786e3 81 unexpected_handler set_unexpected(unexpected_handler) throw();
669f7a03
PE
82 /** The runtime will call this function if an %exception is thrown which
83 * violates the function's %exception specification. */
d34786e3 84 void unexpected() __attribute__ ((__noreturn__));
6305f20a 85
669f7a03
PE
86 /** [18.6.4]/1: "Returns true after completing evaluation of a
87 * throw-expression until either completing initialization of the
88 * exception-declaration in the matching handler or entering @c unexpected()
89 * due to the throw; or after entering @c terminate() for any reason
90 * other than an explicit call to @c terminate(). [Note: This includes
91 * stack unwinding [15.2]. end note]"
92 *
93 * 2: "When @c uncaught_exception() is true, throwing an %exception can
94 * result in a call of @c terminate() (15.5.1)."
95 */
d34786e3 96 bool uncaught_exception() throw();
6305f20a
BK
97} // namespace std
98
1b4a6975
PE
99namespace __gnu_cxx
100{
74a3070f 101 /** A replacement for the standard terminate_handler which prints more
afb0141f
JM
102 information about the terminating exception (if any) on stderr.
103
104 std::set_terminate (__gnu_cxx::__verbose_terminate_handler)
105
106 to use. */
107 void __verbose_terminate_handler ();
74a3070f
JM
108} // namespace __gnu_cxx
109
6305f20a
BK
110} // extern "C++"
111
112#endif