Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/fob1.d

raw
1 // REQUIRED_ARGS: -preview=dip1021
2
3 /* TEST_OUTPUT:
4 ---
5 fail_compilation/fob1.d(104): Error: variable `fob1.foo1.p` has undefined state and cannot be read
6 fail_compilation/fob1.d(104): Error: variable `fob1.foo1.p` is returned but is Undefined
7 ---
8 */
9
10 #line 100
11
12 @live int* foo1()
13 {
14 int* p = void;
15 return p;
16 }
17
18 /* TEST_OUTPUT:
19 ---
20 fail_compilation/fob1.d(204): Error: variable `fob1.foo2.p` assigning to Owner without disposing of owned value
21 fail_compilation/fob1.d(203): Error: variable `fob1.foo2.p` is not disposed of before return
22 ---
23 */
24
25 #line 200
26
27 @live void foo2()
28 {
29 int* p;
30 p = null;
31 }
32
33
34 /* TEST_OUTPUT:
35 ---
36 fail_compilation/fob1.d(304): Error: variable `fob1.foo3.p` has undefined state and cannot be read
37 fail_compilation/fob1.d(304): Error: variable `fob1.foo3.p` is returned but is Undefined
38 fail_compilation/fob1.d(303): Error: variable `fob1.foo3.q` is not disposed of before return
39 ---
40 */
41
42 #line 300
43
44 @live int* foo3(int* p)
45 {
46 int* q = p;
47 return p;
48 }
49
50 /* TEST_OUTPUT:
51 ---
52 fail_compilation/fob1.d(405): Error: variable `fob1.foo4.bq` has undefined state and cannot be read
53 ---
54 */
55
56 #line 400
57
58 @live int* foo4(int* p)
59 {
60 scope int* bq = p;
61 scope const int* cq = p;
62 *bq = 1;
63 return p;
64 }
65
66 /* TEST_OUTPUT:
67 ---
68 fail_compilation/fob1.d(503): Error: more than one mutable reference to `a` in arguments to `fob1.foo5()`
69 ---
70 */
71
72 // https://issues.dlang.org/show_bug.cgi?id=20781
73
74 #line 500
75
76 void test5() {
77 int a;
78 foo5(a, a);
79 }
80
81 @live void foo5(ref int, ref int);