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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [18_support/] [exception_ptr/] [lifespan.cc] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// { dg-options "-std=gnu++0x" }
2
// { dg-require-atomic-builtins "" }
3
 
4
// 2008-05-25  Sebastian Redl  <sebastian.redl@getdesigned.at>
5
 
6
// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
7
//
8
// This file is part of the GNU ISO C++ Library.  This library is free
9
// software; you can redistribute it and/or modify it under the
10
// terms of the GNU General Public License as published by the
11
// Free Software Foundation; either version 3, or (at your option)
12
// any later version.
13
 
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
// GNU General Public License for more details.
18
 
19
// You should have received a copy of the GNU General Public License along
20
// with this library; see the file COPYING3.  If not see
21
// <http://www.gnu.org/licenses/>.
22
 
23
// Tests the life span of the exception object.
24
 
25
#include <exception>
26
#include <testsuite_hooks.h>
27
 
28
bool may_destruct = false;
29
 
30
class destructing
31
{
32
  mutable bool copied;
33
 
34
public:
35
  destructing() : copied(false) { }
36
  destructing(const destructing &o) : copied(false) { o.copied = true; }
37
  ~destructing() { VERIFY( copied || may_destruct ); }
38
};
39
 
40
void test01()
41
{
42
  bool test __attribute__((unused)) = true;
43
  using namespace std;
44
 
45
  may_destruct = false;
46
 
47
  // Test the destructing class.
48
  {
49
    destructing *d = new destructing;
50
    destructing d2(*d);
51
    delete d;
52
    may_destruct = true;
53
  }
54
  may_destruct = false;
55
}
56
 
57
void test02()
58
{
59
  bool test __attribute__((unused)) = true;
60
  using namespace std;
61
 
62
  may_destruct = false;
63
 
64
  try {
65
    throw destructing();
66
  } catch(...) {
67
    may_destruct = true;
68
  }
69
  may_destruct = false;
70
}
71
 
72
void test03()
73
{
74
  bool test __attribute__((unused)) = true;
75
  using namespace std;
76
 
77
  may_destruct = false;
78
 
79
  try {
80
    throw destructing();
81
  } catch(...) {
82
    {
83
      exception_ptr ep = current_exception();
84
    }
85
    may_destruct = true;
86
  }
87
  may_destruct = false;
88
}
89
 
90
void test04()
91
{
92
  bool test __attribute__((unused)) = true;
93
  using namespace std;
94
 
95
  may_destruct = false;
96
 
97
  {
98
    exception_ptr ep;
99
    try {
100
      throw destructing();
101
    } catch(...) {
102
      ep = current_exception();
103
    }
104
    may_destruct = true;
105
  }
106
  may_destruct = false;
107
}
108
 
109
void test05_helper()
110
{
111
  using namespace std;
112
  try {
113
    throw destructing();
114
  } catch(...) {
115
    exception_ptr ep = current_exception();
116
    rethrow_exception(ep);
117
  }
118
}
119
 
120
void test05()
121
{
122
  bool test __attribute__((unused)) = true;
123
  using namespace std;
124
 
125
  may_destruct = false;
126
 
127
  try {
128
    test05_helper();
129
  } catch(...) {
130
    may_destruct = true;
131
  }
132
  may_destruct = false;
133
}
134
 
135
void test06_helper()
136
{
137
  using namespace std;
138
  try {
139
    throw destructing();
140
  } catch(...) {
141
    exception_ptr ep = current_exception();
142
    throw;
143
  }
144
}
145
 
146
void test06()
147
{
148
  bool test __attribute__((unused)) = true;
149
  using namespace std;
150
 
151
  may_destruct = false;
152
 
153
  try
154
    {
155
      test06_helper();
156
    }
157
  catch(...)
158
    {
159
      may_destruct = true;
160
    }
161
  may_destruct = false;
162
}
163
 
164
std::exception_ptr gep;
165
 
166
void test99()
167
{
168
  bool test __attribute__((unused)) = true;
169
  using namespace std;
170
 
171
  may_destruct = false;
172
 
173
  try
174
    {
175
      throw destructing();
176
    }
177
  catch(...)
178
    {
179
      gep = current_exception();
180
    }
181
}
182
 
183
int main()
184
{
185
  test01();
186
  test02();
187
  test03();
188
  test04();
189
  test05();
190
  test06();
191
 
192
  test99();
193
  may_destruct = true;
194
  return 0;
195
}

powered by: WebSVN 2.1.0

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