summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/fob1.d
blob: 1f2312281b466ec5392e50db1f1ae96be9e30e03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// REQUIRED_ARGS: -preview=dip1021

/* TEST_OUTPUT:
---
fail_compilation/fob1.d(104): Error: variable `fob1.foo1.p` has undefined state and cannot be read
fail_compilation/fob1.d(104): Error: variable `fob1.foo1.p` is returned but is Undefined
---
*/

#line 100

@live int* foo1()
{
    int* p = void;
    return p;
}

/* TEST_OUTPUT:
---
fail_compilation/fob1.d(203): Error: variable `fob1.foo2.p` is left dangling at return
---
*/

#line 200

@live void foo2()
{
    int* p;
    p = null;
}


/* TEST_OUTPUT:
---
fail_compilation/fob1.d(304): Error: variable `fob1.foo3.p` has undefined state and cannot be read
fail_compilation/fob1.d(304): Error: variable `fob1.foo3.p` is returned but is Undefined
fail_compilation/fob1.d(303): Error: variable `fob1.foo3.q` is left dangling at return
---
*/

#line 300

@live int* foo3(int* p)
{
    int* q = p;
    return p;
}

/* TEST_OUTPUT:
---
fail_compilation/fob1.d(405): Error: variable `fob1.foo4.bq` has undefined state and cannot be read
---
*/

#line 400

@live int* foo4(int* p)
{
    scope int* bq = p;
    scope const int* cq = p;
    *bq = 1;
    return p;
}