xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/libsupc++/eh_exception.cc (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj // -*- C++ -*- std::exception implementation.
2*38fd1498Szrj // Copyright (C) 1994-2018 Free Software Foundation, Inc.
3*38fd1498Szrj //
4*38fd1498Szrj // This file is part of GCC.
5*38fd1498Szrj //
6*38fd1498Szrj // GCC is free software; you can redistribute it and/or modify
7*38fd1498Szrj // it under the terms of the GNU General Public License as published by
8*38fd1498Szrj // the Free Software Foundation; either version 3, or (at your option)
9*38fd1498Szrj // any later version.
10*38fd1498Szrj //
11*38fd1498Szrj // GCC is distributed in the hope that it will be useful,
12*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*38fd1498Szrj // GNU General Public License for more details.
15*38fd1498Szrj //
16*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional
17*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version
18*38fd1498Szrj // 3.1, as published by the Free Software Foundation.
19*38fd1498Szrj 
20*38fd1498Szrj // You should have received a copy of the GNU General Public License and
21*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program;
22*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23*38fd1498Szrj // <http://www.gnu.org/licenses/>.
24*38fd1498Szrj 
25*38fd1498Szrj #include "typeinfo"
26*38fd1498Szrj #include "exception"
27*38fd1498Szrj #include <cxxabi.h>
28*38fd1498Szrj 
~exception()29*38fd1498Szrj std::exception::~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT { }
30*38fd1498Szrj 
~bad_exception()31*38fd1498Szrj std::bad_exception::~bad_exception() _GLIBCXX_TXN_SAFE_DYN
32*38fd1498Szrj     _GLIBCXX_USE_NOEXCEPT
33*38fd1498Szrj { }
34*38fd1498Szrj 
~__forced_unwind()35*38fd1498Szrj abi::__forced_unwind::~__forced_unwind() throw() { }
36*38fd1498Szrj 
~__foreign_exception()37*38fd1498Szrj abi::__foreign_exception::~__foreign_exception() throw() { }
38*38fd1498Szrj 
39*38fd1498Szrj const char*
what() const40*38fd1498Szrj std::exception::what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT
41*38fd1498Szrj {
42*38fd1498Szrj   // NB: Another elegant option would be returning typeid(*this).name()
43*38fd1498Szrj   // and not overriding what() in bad_exception, bad_alloc, etc.  In
44*38fd1498Szrj   // that case, however, mangled names would be returned, PR 14493.
45*38fd1498Szrj   return "std::exception";
46*38fd1498Szrj }
47*38fd1498Szrj 
48*38fd1498Szrj const char*
what() const49*38fd1498Szrj std::bad_exception::what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT
50*38fd1498Szrj {
51*38fd1498Szrj   return "std::bad_exception";
52*38fd1498Szrj }
53*38fd1498Szrj 
54*38fd1498Szrj // Transactional clones for the destructors and what().
55*38fd1498Szrj // what() is effectively transaction_pure, but we do not want to annotate it
56*38fd1498Szrj // as such; thus, we call exactly the respective nontransactional function.
57*38fd1498Szrj extern "C" {
58*38fd1498Szrj 
59*38fd1498Szrj void
_ZGTtNKSt9exceptionD1Ev(const std::exception *)60*38fd1498Szrj _ZGTtNKSt9exceptionD1Ev(const std::exception*)
61*38fd1498Szrj { }
62*38fd1498Szrj 
63*38fd1498Szrj const char*
_ZGTtNKSt9exception4whatEv(const std::exception * that)64*38fd1498Szrj _ZGTtNKSt9exception4whatEv(const std::exception* that)
65*38fd1498Szrj {
66*38fd1498Szrj   // We really want the non-virtual call here.  We already executed the
67*38fd1498Szrj   // indirect call representing the virtual call, and the TM runtime or the
68*38fd1498Szrj   // compiler resolved it to this transactional clone.  In the clone, we want
69*38fd1498Szrj   // to do the same as for the nontransactional original, so we just call it.
70*38fd1498Szrj   return that->std::exception::what();
71*38fd1498Szrj }
72*38fd1498Szrj 
73*38fd1498Szrj void
_ZGTtNKSt13bad_exceptionD1Ev(const std::bad_exception *)74*38fd1498Szrj _ZGTtNKSt13bad_exceptionD1Ev(
75*38fd1498Szrj     const std::bad_exception*)
76*38fd1498Szrj { }
77*38fd1498Szrj 
78*38fd1498Szrj const char*
_ZGTtNKSt13bad_exception4whatEv(const std::bad_exception * that)79*38fd1498Szrj _ZGTtNKSt13bad_exception4whatEv(
80*38fd1498Szrj     const std::bad_exception* that)
81*38fd1498Szrj {
82*38fd1498Szrj   // Also see _ZGTtNKSt9exception4whatEv.
83*38fd1498Szrj   return that->std::bad_exception::what();
84*38fd1498Szrj }
85*38fd1498Szrj 
86*38fd1498Szrj }
87