xref: /netbsd-src/external/gpl3/gcc.old/dist/libstdc++-v3/libsupc++/eh_exception.cc (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg // -*- C++ -*- std::exception implementation.
2*8feb0f0bSmrg // Copyright (C) 1994-2020 Free Software Foundation, Inc.
31debfc3dSmrg //
41debfc3dSmrg // This file is part of GCC.
51debfc3dSmrg //
61debfc3dSmrg // GCC is free software; you can redistribute it and/or modify
71debfc3dSmrg // it under the terms of the GNU General Public License as published by
81debfc3dSmrg // the Free Software Foundation; either version 3, or (at your option)
91debfc3dSmrg // any later version.
101debfc3dSmrg //
111debfc3dSmrg // GCC is distributed in the hope that it will be useful,
121debfc3dSmrg // but WITHOUT ANY WARRANTY; without even the implied warranty of
131debfc3dSmrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
141debfc3dSmrg // GNU General Public License for more details.
151debfc3dSmrg //
161debfc3dSmrg // Under Section 7 of GPL version 3, you are granted additional
171debfc3dSmrg // permissions described in the GCC Runtime Library Exception, version
181debfc3dSmrg // 3.1, as published by the Free Software Foundation.
191debfc3dSmrg 
201debfc3dSmrg // You should have received a copy of the GNU General Public License and
211debfc3dSmrg // a copy of the GCC Runtime Library Exception along with this program;
221debfc3dSmrg // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
231debfc3dSmrg // <http://www.gnu.org/licenses/>.
241debfc3dSmrg 
251debfc3dSmrg #include "typeinfo"
261debfc3dSmrg #include "exception"
271debfc3dSmrg #include <cxxabi.h>
281debfc3dSmrg 
~exception()291debfc3dSmrg std::exception::~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT { }
301debfc3dSmrg 
~bad_exception()311debfc3dSmrg std::bad_exception::~bad_exception() _GLIBCXX_TXN_SAFE_DYN
321debfc3dSmrg     _GLIBCXX_USE_NOEXCEPT
331debfc3dSmrg { }
341debfc3dSmrg 
~__forced_unwind()351debfc3dSmrg abi::__forced_unwind::~__forced_unwind() throw() { }
361debfc3dSmrg 
~__foreign_exception()371debfc3dSmrg abi::__foreign_exception::~__foreign_exception() throw() { }
381debfc3dSmrg 
391debfc3dSmrg const char*
what() const401debfc3dSmrg std::exception::what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT
411debfc3dSmrg {
421debfc3dSmrg   // NB: Another elegant option would be returning typeid(*this).name()
431debfc3dSmrg   // and not overriding what() in bad_exception, bad_alloc, etc.  In
441debfc3dSmrg   // that case, however, mangled names would be returned, PR 14493.
451debfc3dSmrg   return "std::exception";
461debfc3dSmrg }
471debfc3dSmrg 
481debfc3dSmrg const char*
what() const491debfc3dSmrg std::bad_exception::what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT
501debfc3dSmrg {
511debfc3dSmrg   return "std::bad_exception";
521debfc3dSmrg }
531debfc3dSmrg 
541debfc3dSmrg // Transactional clones for the destructors and what().
551debfc3dSmrg // what() is effectively transaction_pure, but we do not want to annotate it
561debfc3dSmrg // as such; thus, we call exactly the respective nontransactional function.
571debfc3dSmrg extern "C" {
581debfc3dSmrg 
591debfc3dSmrg void
_ZGTtNKSt9exceptionD1Ev(const std::exception *)601debfc3dSmrg _ZGTtNKSt9exceptionD1Ev(const std::exception*)
611debfc3dSmrg { }
621debfc3dSmrg 
631debfc3dSmrg const char*
_ZGTtNKSt9exception4whatEv(const std::exception * that)641debfc3dSmrg _ZGTtNKSt9exception4whatEv(const std::exception* that)
651debfc3dSmrg {
661debfc3dSmrg   // We really want the non-virtual call here.  We already executed the
671debfc3dSmrg   // indirect call representing the virtual call, and the TM runtime or the
681debfc3dSmrg   // compiler resolved it to this transactional clone.  In the clone, we want
691debfc3dSmrg   // to do the same as for the nontransactional original, so we just call it.
701debfc3dSmrg   return that->std::exception::what();
711debfc3dSmrg }
721debfc3dSmrg 
731debfc3dSmrg void
_ZGTtNKSt13bad_exceptionD1Ev(const std::bad_exception *)741debfc3dSmrg _ZGTtNKSt13bad_exceptionD1Ev(
751debfc3dSmrg     const std::bad_exception*)
761debfc3dSmrg { }
771debfc3dSmrg 
781debfc3dSmrg const char*
_ZGTtNKSt13bad_exception4whatEv(const std::bad_exception * that)791debfc3dSmrg _ZGTtNKSt13bad_exception4whatEv(
801debfc3dSmrg     const std::bad_exception* that)
811debfc3dSmrg {
821debfc3dSmrg   // Also see _ZGTtNKSt9exception4whatEv.
831debfc3dSmrg   return that->std::bad_exception::what();
841debfc3dSmrg }
851debfc3dSmrg 
861debfc3dSmrg }
87