d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fob1.d
blobd11a7a69916ee4d22de6e3edfca3b607062c1c70
1 // REQUIRED_ARGS: -preview=dip1021
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 */
10 #line 100
12 @live int* foo1()
14 int* p = void;
15 return p;
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 ---
25 #line 200
27 @live void foo2()
29 int* p;
30 p = null;
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 ---
42 #line 300
44 @live int* foo3(int* p)
46 int* q = p;
47 return p;
50 /* TEST_OUTPUT:
51 ---
52 fail_compilation/fob1.d(405): Error: variable `fob1.foo4.bq` has undefined state and cannot be read
53 ---
56 #line 400
58 @live int* foo4(int* p)
60 scope int* bq = p;
61 scope const int* cq = p;
62 *bq = 1;
63 return p;
66 /* TEST_OUTPUT:
67 ---
68 fail_compilation/fob1.d(503): Error: more than one mutable reference to `a` in arguments to `fob1.foo5()`
69 ---
72 // https://issues.dlang.org/show_bug.cgi?id=20781
74 #line 500
76 void test5() {
77 int a;
78 foo5(a, a);
81 @live void foo5(ref int, ref int);