middle-end: Lower all gconds during vector pattern matching [PR117176]
[official-gcc.git] / libstdc++-v3 / testsuite / 18_support / exception / 38732.cc
blob1f24f2438469a3db7a618752dbffd1eb37402571
1 // Copyright (C) 2009-2024 Free Software Foundation, Inc.
2 //
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)
7 // any later version.
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 } } } }
20 #include <typeinfo>
21 #include <exception>
22 #include "unwind.h"
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.
29 // Ensure it is true.
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;
38 int handlerCount;
39 #ifdef __ARM_EABI_UNWINDER__
40 __cxa_exception* nextPropagatingException;
41 int propagationCount;
42 #else
43 int handlerSwitchValue;
44 const unsigned char *actionRecord;
45 const unsigned char *languageSpecificData;
46 _Unwind_Ptr catchTemp;
47 void *adjustedPtr;
48 #endif
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;
58 #endif
61 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
63 // PR libstdc++/38732
64 void test01 ()
66 try {
67 throw 0;
68 } catch(...) {
69 __cxa_exception *exc = __cxa_get_globals()->caughtExceptions;
70 VERIFY ( exc != 0 );
71 #if __cpp_rtti
72 VERIFY ( typeid(int) == *exc->exceptionType );
73 #endif
75 try {
76 throw 0LL;
77 } catch(...) {
78 __cxa_exception *exc = __cxa_get_globals()->caughtExceptions;
79 VERIFY ( exc != 0 );
80 #if __cpp_rtti
81 VERIFY ( typeid(long long int) == *exc->exceptionType );
82 #endif
84 try {
85 throw 0.0;
86 } catch(...) {
87 __cxa_exception *exc = __cxa_get_globals()->caughtExceptions;
88 VERIFY ( exc != 0 );
89 #if __cpp_rtti
90 VERIFY ( typeid(double) == *exc->exceptionType );
91 #endif
95 int main ()
97 test01 ();