1 // Copyright (C) 2009-2024 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target { c++11 && { ! c++23 } } } }
23 #include <testsuite_hooks.h>
25 // Before exception_ptr was introduced, some programs copied
26 // part of unwind-cxx.h and used __cxa_get_globals to get at the
27 // current exceptionType. __cxa_exception structure is described in the
28 // C++ ABI, so they have the right to assume it works.
31 struct __cxa_exception
33 std::type_info
*exceptionType
;
34 void (*exceptionDestructor
)(void *);
35 std::unexpected_handler unexpectedHandler
;
36 std::terminate_handler terminateHandler
;
37 __cxa_exception
*nextException
;
39 #ifdef __ARM_EABI_UNWINDER__
40 __cxa_exception
* nextPropagatingException
;
43 int handlerSwitchValue
;
44 const unsigned char *actionRecord
;
45 const unsigned char *languageSpecificData
;
46 _Unwind_Ptr catchTemp
;
49 _Unwind_Exception unwindHeader
;
52 struct __cxa_eh_globals
54 __cxa_exception
*caughtExceptions
;
55 unsigned int uncaughtExceptions
;
56 #ifdef __ARM_EABI_UNWINDER__
57 __cxa_exception
* propagatingExceptions
;
61 extern "C" __cxa_eh_globals
*__cxa_get_globals () throw();
69 __cxa_exception
*exc
= __cxa_get_globals()->caughtExceptions
;
72 VERIFY ( typeid(int) == *exc
->exceptionType
);
78 __cxa_exception
*exc
= __cxa_get_globals()->caughtExceptions
;
81 VERIFY ( typeid(long long int) == *exc
->exceptionType
);
87 __cxa_exception
*exc
= __cxa_get_globals()->caughtExceptions
;
90 VERIFY ( typeid(double) == *exc
->exceptionType
);