Debian Codegraph @

gcc/testsuite/gdc.test/compilable/warn12809.d

raw
1 // REQUIRED_ARGS: -o- -w
2
3 /*
4 Warning removed in: https://github.com/dlang/dmd/pull/15568
5 ---
6 fail_compilation/warn12809.d(25): Warning: statement is not reachable
7 fail_compilation/warn12809.d(33): Warning: statement is not reachable
8 ---
9 */
10
11 //void test_unrachable1()
12 //{
13 // try assert(0);
14 // finally
15 // {
16 // int x = 1; // unreachable
17 // }
18 //}
19
20 void test_unrachable2()
21 {
22 try assert(0);
23 finally {}
24
25 int x = 1; // unreachable
26 }
27
28 void test_unrachable3()
29 {
30 try {}
31 finally assert(0);
32
33 int x = 1; // unreachable
34 }
35
36 /********************************************/
37
38 /*
39
40 ---
41 fail_compilation/warn12809.d(108): Warning: statement is not reachable
42 fail_compilation/warn12809.d(115): Warning: statement is not reachable
43 fail_compilation/warn12809.d(122): Warning: statement is not reachable
44 Error: warnings are treated as errors
45 Use -wi if you wish to treat warnings only as informational.
46 ---
47 */
48
49 #line 100
50
51 alias noreturn = typeof(*null);
52
53 noreturn foo();
54
55 void test1(ref int i)
56 {
57 foo();
58 i = 3;
59 }
60
61 void test2()
62 {
63 try foo();
64 finally { }
65 int x = 1;
66 }
67
68 void test3()
69 {
70 try { }
71 finally foo();
72 int x = 1;
73 }
74
75 // https://issues.dlang.org/show_bug.cgi?id=14835
76 bool isEven(int i)()
77 {
78 static if (i % 2)
79 return true;
80 return false;
81 }
82
83 enum x = isEven!0;
84
85 // https://issues.dlang.org/show_bug.cgi?id=10532
86 alias Seq(T...) = T;
87 void f()
88 {
89 foreach (e; Seq!(10, 20))
90 {
91 if (e == 10)
92 continue;
93
94 // lots of code follows..
95 auto x = 1;
96 }
97 }