1 // { dg-do run { target c++11 } }
2
3 // Test throw and catch
4
5 extern "C" void abort (void);
6
7 typedef decltype(nullptr) nullptr_t;
8
9 int result[2];
10
11 void __attribute__((noinline))
foo(int i,int j)12 foo (int i, int j)
13 {
14 result[i] = j;
15 }
16
main()17 int main()
18 {
19 try {
20 throw nullptr;
21 } catch (bool) {
22 foo (0, 2);
23 } catch (int) {
24 foo (0, 3);
25 } catch (long int) {
26 foo (0, 4);
27 } catch (nullptr_t) {
28 foo (0, 5);
29 } catch (...) {
30 foo (0, 6);
31 }
32
33 nullptr_t mynull = 0;
34 try {
35 throw mynull;
36 } catch (bool) {
37 foo (1, 2);
38 } catch (int) {
39 foo (1, 3);
40 } catch (long int) {
41 foo (1, 4);
42 } catch (nullptr_t) {
43 foo (1, 5);
44 } catch (...) {
45 foo (1, 6);
46 }
47
48 if (result[0] != 5 || result[1] != 5)
49 abort ();
50 }
51