xref: /netbsd-src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_exception.cc (revision b1e838363e3c6fc78a55519254d99869742dd33c)
14fee23f9Smrg // -*- C++ -*- std::exception implementation.
2*b1e83836Smrg // Copyright (C) 1994-2022 Free Software Foundation, Inc.
34fee23f9Smrg //
44fee23f9Smrg // This file is part of GCC.
54fee23f9Smrg //
64fee23f9Smrg // GCC is free software; you can redistribute it and/or modify
74fee23f9Smrg // it under the terms of the GNU General Public License as published by
84fee23f9Smrg // the Free Software Foundation; either version 3, or (at your option)
94fee23f9Smrg // any later version.
104fee23f9Smrg //
114fee23f9Smrg // GCC is distributed in the hope that it will be useful,
124fee23f9Smrg // but WITHOUT ANY WARRANTY; without even the implied warranty of
134fee23f9Smrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144fee23f9Smrg // GNU General Public License for more details.
154fee23f9Smrg //
164fee23f9Smrg // Under Section 7 of GPL version 3, you are granted additional
174fee23f9Smrg // permissions described in the GCC Runtime Library Exception, version
184fee23f9Smrg // 3.1, as published by the Free Software Foundation.
194fee23f9Smrg 
204fee23f9Smrg // You should have received a copy of the GNU General Public License and
214fee23f9Smrg // a copy of the GCC Runtime Library Exception along with this program;
224fee23f9Smrg // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
234fee23f9Smrg // <http://www.gnu.org/licenses/>.
244fee23f9Smrg 
254fee23f9Smrg #include "typeinfo"
264fee23f9Smrg #include "exception"
274fee23f9Smrg #include <cxxabi.h>
284fee23f9Smrg 
~exception()29f9a78e0eSmrg std::exception::~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT { }
304fee23f9Smrg 
~bad_exception()31f9a78e0eSmrg std::bad_exception::~bad_exception() _GLIBCXX_TXN_SAFE_DYN
32f9a78e0eSmrg     _GLIBCXX_USE_NOEXCEPT
33f9a78e0eSmrg { }
344fee23f9Smrg 
~__forced_unwind()354fee23f9Smrg abi::__forced_unwind::~__forced_unwind() throw() { }
364fee23f9Smrg 
~__foreign_exception()374fee23f9Smrg abi::__foreign_exception::~__foreign_exception() throw() { }
384fee23f9Smrg 
394fee23f9Smrg const char*
what() const40f9a78e0eSmrg std::exception::what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT
414fee23f9Smrg {
424fee23f9Smrg   // NB: Another elegant option would be returning typeid(*this).name()
434fee23f9Smrg   // and not overriding what() in bad_exception, bad_alloc, etc.  In
444fee23f9Smrg   // that case, however, mangled names would be returned, PR 14493.
454fee23f9Smrg   return "std::exception";
464fee23f9Smrg }
474fee23f9Smrg 
484fee23f9Smrg const char*
what() const49f9a78e0eSmrg std::bad_exception::what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT
504fee23f9Smrg {
514fee23f9Smrg   return "std::bad_exception";
524fee23f9Smrg }
53f9a78e0eSmrg 
54f9a78e0eSmrg // Transactional clones for the destructors and what().
55f9a78e0eSmrg // what() is effectively transaction_pure, but we do not want to annotate it
56f9a78e0eSmrg // as such; thus, we call exactly the respective nontransactional function.
57f9a78e0eSmrg extern "C" {
58f9a78e0eSmrg 
59f9a78e0eSmrg void
_ZGTtNKSt9exceptionD1Ev(const std::exception *)60f9a78e0eSmrg _ZGTtNKSt9exceptionD1Ev(const std::exception*)
61f9a78e0eSmrg { }
62f9a78e0eSmrg 
63f9a78e0eSmrg const char*
_ZGTtNKSt9exception4whatEv(const std::exception * that)64f9a78e0eSmrg _ZGTtNKSt9exception4whatEv(const std::exception* that)
65f9a78e0eSmrg {
66f9a78e0eSmrg   // We really want the non-virtual call here.  We already executed the
67f9a78e0eSmrg   // indirect call representing the virtual call, and the TM runtime or the
68f9a78e0eSmrg   // compiler resolved it to this transactional clone.  In the clone, we want
69f9a78e0eSmrg   // to do the same as for the nontransactional original, so we just call it.
70f9a78e0eSmrg   return that->std::exception::what();
71f9a78e0eSmrg }
72f9a78e0eSmrg 
73f9a78e0eSmrg void
_ZGTtNKSt13bad_exceptionD1Ev(const std::bad_exception *)74f9a78e0eSmrg _ZGTtNKSt13bad_exceptionD1Ev(
75f9a78e0eSmrg     const std::bad_exception*)
76f9a78e0eSmrg { }
77f9a78e0eSmrg 
78f9a78e0eSmrg const char*
_ZGTtNKSt13bad_exception4whatEv(const std::bad_exception * that)79f9a78e0eSmrg _ZGTtNKSt13bad_exception4whatEv(
80f9a78e0eSmrg     const std::bad_exception* that)
81f9a78e0eSmrg {
82f9a78e0eSmrg   // Also see _ZGTtNKSt9exception4whatEv.
83f9a78e0eSmrg   return that->std::bad_exception::what();
84f9a78e0eSmrg }
85f9a78e0eSmrg 
86f9a78e0eSmrg }
87