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