xref: /freebsd/contrib/libcxxrt/stdexcept.h (revision 13da1af1cd677b7901d3bf4b9dbe3290b94130d5)
194e3ee44SDavid Chisnall /*
294e3ee44SDavid Chisnall  * Copyright 2010-2011 PathScale, Inc. All rights reserved.
394e3ee44SDavid Chisnall  *
494e3ee44SDavid Chisnall  * Redistribution and use in source and binary forms, with or without
594e3ee44SDavid Chisnall  * modification, are permitted provided that the following conditions are met:
694e3ee44SDavid Chisnall  *
794e3ee44SDavid Chisnall  * 1. Redistributions of source code must retain the above copyright notice,
894e3ee44SDavid Chisnall  *    this list of conditions and the following disclaimer.
994e3ee44SDavid Chisnall  *
1094e3ee44SDavid Chisnall  * 2. Redistributions in binary form must reproduce the above copyright notice,
1194e3ee44SDavid Chisnall  *    this list of conditions and the following disclaimer in the documentation
1294e3ee44SDavid Chisnall  *    and/or other materials provided with the distribution.
1394e3ee44SDavid Chisnall  *
1494e3ee44SDavid Chisnall  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
1594e3ee44SDavid Chisnall  * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1694e3ee44SDavid Chisnall  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1794e3ee44SDavid Chisnall  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
1894e3ee44SDavid Chisnall  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1994e3ee44SDavid Chisnall  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2094e3ee44SDavid Chisnall  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2194e3ee44SDavid Chisnall  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2294e3ee44SDavid Chisnall  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2394e3ee44SDavid Chisnall  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2494e3ee44SDavid Chisnall  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2594e3ee44SDavid Chisnall  */
2694e3ee44SDavid Chisnall 
277a984708SDavid Chisnall /**
287a984708SDavid Chisnall  * stdexcept.h - provides a stub version of <stdexcept>, which defines enough
297a984708SDavid Chisnall  * of the exceptions for the runtime to use.
307a984708SDavid Chisnall  */
317a984708SDavid Chisnall 
32*13da1af1SEd Maste #include "cxxabi.h"
33*13da1af1SEd Maste 
347a984708SDavid Chisnall namespace std
357a984708SDavid Chisnall {
367a984708SDavid Chisnall 
377a984708SDavid Chisnall 	class exception
387a984708SDavid Chisnall 	{
397a984708SDavid Chisnall 	public:
40*13da1af1SEd Maste 		exception() _LIBCXXRT_NOEXCEPT;
41*13da1af1SEd Maste 		exception(const exception&) _LIBCXXRT_NOEXCEPT;
42*13da1af1SEd Maste 		exception& operator=(const exception&) _LIBCXXRT_NOEXCEPT;
437a984708SDavid Chisnall 		virtual ~exception();
44*13da1af1SEd Maste 		virtual const char* what() const _LIBCXXRT_NOEXCEPT;
457a984708SDavid Chisnall 	};
467a984708SDavid Chisnall 
477a984708SDavid Chisnall 
487a984708SDavid Chisnall 	/**
497a984708SDavid Chisnall 	 * Bad allocation exception.  Thrown by ::operator new() if it fails.
507a984708SDavid Chisnall 	 */
517a984708SDavid Chisnall 	class bad_alloc: public exception
527a984708SDavid Chisnall 	{
537a984708SDavid Chisnall 	public:
54*13da1af1SEd Maste 		bad_alloc() _LIBCXXRT_NOEXCEPT;
55*13da1af1SEd Maste 		bad_alloc(const bad_alloc&) _LIBCXXRT_NOEXCEPT;
56*13da1af1SEd Maste 		bad_alloc& operator=(const bad_alloc&) _LIBCXXRT_NOEXCEPT;
577a984708SDavid Chisnall 		~bad_alloc();
58*13da1af1SEd Maste 		virtual const char* what() const _LIBCXXRT_NOEXCEPT;
597a984708SDavid Chisnall 	};
607a984708SDavid Chisnall 
617a984708SDavid Chisnall 	/**
627a984708SDavid Chisnall 	 * Bad cast exception.  Thrown by the __cxa_bad_cast() helper function.
637a984708SDavid Chisnall 	 */
647a984708SDavid Chisnall 	class bad_cast: public exception {
657a984708SDavid Chisnall 	public:
66*13da1af1SEd Maste 		bad_cast() _LIBCXXRT_NOEXCEPT;
67*13da1af1SEd Maste 		bad_cast(const bad_cast&) _LIBCXXRT_NOEXCEPT;
68*13da1af1SEd Maste 		bad_cast& operator=(const bad_cast&) _LIBCXXRT_NOEXCEPT;
697a984708SDavid Chisnall 		virtual ~bad_cast();
70*13da1af1SEd Maste 		virtual const char* what() const _LIBCXXRT_NOEXCEPT;
717a984708SDavid Chisnall 	};
727a984708SDavid Chisnall 
737a984708SDavid Chisnall 	/**
747a984708SDavid Chisnall 	 * Bad typeidexception.  Thrown by the __cxa_bad_typeid() helper function.
757a984708SDavid Chisnall 	 */
767a984708SDavid Chisnall 	class bad_typeid: public exception
777a984708SDavid Chisnall 	{
787a984708SDavid Chisnall 	public:
79*13da1af1SEd Maste 		bad_typeid() _LIBCXXRT_NOEXCEPT;
80*13da1af1SEd Maste 		bad_typeid(const bad_typeid &__rhs) _LIBCXXRT_NOEXCEPT;
817a984708SDavid Chisnall 		virtual ~bad_typeid();
82*13da1af1SEd Maste 		bad_typeid& operator=(const bad_typeid &__rhs) _LIBCXXRT_NOEXCEPT;
83*13da1af1SEd Maste 		virtual const char* what() const _LIBCXXRT_NOEXCEPT;
847a984708SDavid Chisnall 	};
857a984708SDavid Chisnall 
86f2dc4184SDimitry Andric 	class bad_array_new_length: public bad_alloc
87726f4cd5SBaptiste Daroussin 	{
88726f4cd5SBaptiste Daroussin 	public:
89*13da1af1SEd Maste 		bad_array_new_length() _LIBCXXRT_NOEXCEPT;
90*13da1af1SEd Maste 		bad_array_new_length(const bad_array_new_length&) _LIBCXXRT_NOEXCEPT;
91*13da1af1SEd Maste 		bad_array_new_length& operator=(const bad_array_new_length&) _LIBCXXRT_NOEXCEPT;
92726f4cd5SBaptiste Daroussin 		virtual ~bad_array_new_length();
93*13da1af1SEd Maste 		virtual const char *what() const _LIBCXXRT_NOEXCEPT;
94726f4cd5SBaptiste Daroussin 	};
957a984708SDavid Chisnall 
967a984708SDavid Chisnall 
977a984708SDavid Chisnall } // namespace std
987a984708SDavid Chisnall 
99