Debian Codegraph @

gcc/testsuite/g++.dg/warn/noreturn-1.C

raw
1 // Test that noreturn attributes are properly set.
2 // Origin: Kaveh Ghazi <[email protected]> 2002-06-18.
3 // { dg-do compile }
4 // { dg-options "-Wall -O2" }
5 // { dg-skip-if "requires hosted libstdc++ for cstdlib abort" { ! hostedlib } }
6
7 #include <cstdlib>
8
9 int foo1 (int i)
10 {
11 switch (i)
12 {
13 case 1:
14 case 2:
15 return i;
16 }
17 abort();
18 }
19
20 int foo2 (int i)
21 {
22 switch (i)
23 {
24 case 1:
25 case 2:
26 return i;
27 }
28 std::abort();
29 }
30
31 int foo3 (int i)
32 {
33 switch (i)
34 {
35 case 1:
36 case 2:
37 return i;
38 }
39 exit(1);
40 }
41
42 int foo4 (int i)
43 {
44 switch (i)
45 {
46 case 1:
47 case 2:
48 return i;
49 }
50 std::exit(1);
51 }
52
53 void __attribute__ ((__noreturn__)) foo5 ()
54 {
55 abort();
56 }
57
58 void __attribute__ ((__noreturn__)) foo6 ()
59 {
60 std::abort();
61 }
62
63 void __attribute__ ((__noreturn__)) foo7 ()
64 {
65 exit(1);
66 }
67
68 void __attribute__ ((__noreturn__)) foo8 ()
69 {
70 std::exit(1);
71 }
72