OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libstdc++-v3/] [testsuite/] [18_support/] [exception/] [38732.cc] - Blame information for rev 424

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// Copyright (C) 2009 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.
8
 
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.
13
 
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/>.
17
 
18
#include <typeinfo>
19
#include <exception>
20
#include <cstddef>
21
#include "unwind.h"
22
#include <testsuite_hooks.h>
23
 
24
// Before exception_ptr was introduced, some programs copied
25
// part of unwind-cxx.h and used __cxa_get_globals to get at the
26
// current exceptionType.  __cxa_exception structure is described in the
27
// C++ ABI, so they have the right to assume it works.
28
// Ensure it is true.
29
 
30
struct __cxa_exception
31
{
32
  std::type_info *exceptionType;
33
  void (*exceptionDestructor)(void *);
34
  std::unexpected_handler unexpectedHandler;
35
  std::terminate_handler terminateHandler;
36
  __cxa_exception *nextException;
37
  int handlerCount;
38
#ifdef __ARM_EABI_UNWINDER__
39
  __cxa_exception* nextPropagatingException;
40
  int propagationCount;
41
#else
42
  int handlerSwitchValue;
43
  const unsigned char *actionRecord;
44
  const unsigned char *languageSpecificData;
45
  _Unwind_Ptr catchTemp;
46
  void *adjustedPtr;
47
#endif
48
  _Unwind_Exception unwindHeader;
49
};
50
 
51
struct __cxa_eh_globals
52
{
53
  __cxa_exception *caughtExceptions;
54
  unsigned int uncaughtExceptions;
55
#ifdef __ARM_EABI_UNWINDER__
56
  __cxa_exception* propagatingExceptions;
57
#endif
58
};
59
 
60
extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
61
 
62
// PR libstdc++/38732
63
void test01 ()
64
{
65
  bool test __attribute__((unused)) = true;
66
  try {
67
    throw 0;
68
  } catch(...) {
69
    __cxa_exception *exc = __cxa_get_globals()->caughtExceptions;
70
    VERIFY ( exc != NULL );
71
    VERIFY ( typeid(int) == *exc->exceptionType );
72
  }
73
  try {
74
    throw 0LL;
75
  } catch(...) {
76
    __cxa_exception *exc = __cxa_get_globals()->caughtExceptions;
77
    VERIFY ( exc != NULL );
78
    VERIFY ( typeid(long long int) == *exc->exceptionType );
79
  }
80
  try {
81
    throw 0.0;
82
  } catch(...) {
83
    __cxa_exception *exc = __cxa_get_globals()->caughtExceptions;
84
    VERIFY ( exc != NULL );
85
    VERIFY ( typeid(double) == *exc->exceptionType );
86
  }
87
}
88
 
89
int main ()
90
{
91
  test01 ();
92
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.