annotate gcc/testsuite/g++.dg/cpp0x/noexcept04.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Make sure that we call terminate when a noexcept spec is violated.
kono
parents:
diff changeset
2 // The function pointers are there to make sure that
kono
parents:
diff changeset
3 // the compiler doesn't get clever about optimizing the calls based on
kono
parents:
diff changeset
4 // knowledge about the called functions.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 // { dg-do run { target c++11 } }
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 #include <exception>
kono
parents:
diff changeset
9 #include <cstdlib>
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 void my_terminate ()
kono
parents:
diff changeset
12 {
kono
parents:
diff changeset
13 std::exit (0);
kono
parents:
diff changeset
14 }
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 void g() { throw 1; }
kono
parents:
diff changeset
17 void (*p1)() = g;
kono
parents:
diff changeset
18 void f() noexcept { p1(); }
kono
parents:
diff changeset
19 void (*p2)() = f;
kono
parents:
diff changeset
20 void h() { p2(); }
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 int main()
kono
parents:
diff changeset
23 {
kono
parents:
diff changeset
24 std::set_terminate (my_terminate);
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 try { h(); }
kono
parents:
diff changeset
27 catch (int) { }
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 return 1;
kono
parents:
diff changeset
30 }