]> git.ipfire.org Git - people/ms/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/failob2.d
d: Merge upstream dmd, druntime 4ca4140e58, phobos 454dff14d.
[people/ms/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / failob2.d
1 // REQUIRED_ARGS: -preview=dip1021
2
3 /*
4 TEST_OUTPUT:
5 ---
6 fail_compilation/failob2.d(105): Error: variable `failob2.foo1!int.foo1.p` has undefined state and cannot be read
7 fail_compilation/failob2.d(105): Error: variable `failob2.foo1!int.foo1.p` is returned but is Undefined
8 fail_compilation/failob2.d(124): Error: template instance `failob2.foo1!int` error instantiating
9 fail_compilation/failob2.d(111): Error: variable `failob2.foo2!int.foo2.p` has undefined state and cannot be read
10 fail_compilation/failob2.d(111): Error: variable `failob2.foo2!int.foo2.p` is returned but is Undefined
11 fail_compilation/failob2.d(125): Error: template instance `failob2.foo2!int` error instantiating
12 fail_compilation/failob2.d(119): Error: variable `failob2.foo3!int.foo3.p` has undefined state and cannot be read
13 fail_compilation/failob2.d(119): Error: variable `failob2.foo3!int.foo3.p` is returned but is Undefined
14 fail_compilation/failob2.d(126): Error: template instance `failob2.foo3!int` error instantiating
15 ---
16 */
17
18 #line 100
19
20 @live
21 T* foo1(T)()
22 {
23 T* p = void;
24 return p;
25 }
26
27 template foo2(T) {
28 @live T* foo2() {
29 T* p = void;
30 return p;
31 }
32 }
33
34 @live
35 template foo3(T) {
36 T* foo3() {
37 T* p = void;
38 return p;
39 }
40 }
41
42 void test1() {
43 foo1!int();
44 foo2!int();
45 foo3!int();
46 }
47
48 /*
49 TEST_OUTPUT:
50 ---
51 fail_compilation/failob2.d(205): Error: variable `failob2.foo4!int.foo4.p` is not disposed of before return
52 fail_compilation/failob2.d(209): Error: template instance `failob2.foo4!int` error instantiating
53 ---
54 */
55
56 #line 200
57
58 void* alloc(size_t);
59
60 @live void foo4(T)()
61 {
62 auto p = alloc(4);
63 }
64
65 void test2() {
66 foo4!int();
67 }