blob: 3e1655e83ec8fb016a9720cbb8fb015d200a4d3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Tests that the exceptions declared by the TM TS (N4514) as transaction_safe
// are indeed that. Thus, this also tests the transactional clones in
// libstdc++ and libsupc++.
// { dg-do run }
#include <iostream>
#include <exception>
#include <stdexcept>
#include <string>
using namespace std;
template<typename T> void thrower(const T& t)
{
try
{
atomic_commit
{
throw t;
}
}
catch (T ex)
{
if (ex != t) abort ();
}
}
template<typename T> void thrower1(const string& what)
{
try
{
atomic_commit
{
throw T ();
}
}
catch (T ex)
{
if (what != ex.what()) abort ();
}
}
template<typename T> void thrower2(const string& what)
{
try
{
atomic_commit
{
throw T (what);
}
}
catch (T ex)
{
if (what != ex.what()) abort ();
}
}
int main ()
{
thrower<unsigned int> (23);
thrower<int> (23);
thrower<unsigned short> (23);
thrower<short> (23);
thrower<unsigned char> (23);
thrower<char> (23);
thrower<unsigned long int> (42);
thrower<long int> (42);
thrower<unsigned long long int> (42);
thrower<long long int> (42);
thrower<double> (23.42);
thrower<long double> (23.42);
thrower<float> (23.42);
thrower<void*> (0);
thrower<void**> (0);
thrower1<exception> ("std::exception");
thrower1<bad_exception> ("std::bad_exception");
thrower2<logic_error> ("test");
thrower2<domain_error> ("test");
thrower2<invalid_argument> ("test");
thrower2<length_error> ("test");
thrower2<out_of_range> ("test");
thrower2<runtime_error> ("test");
thrower2<range_error> ("test");
thrower2<overflow_error> ("test");
thrower2<underflow_error> ("test");
return 0;
}
|