aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/debugInference.d
blob: 947d820fcac228692550031e82bc252353221c1e (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
/*
REQUIRED_ARGS: -debug
https://issues.dlang.org/show_bug.cgi?id=20507
*/


void main() pure  nothrow @safe @nogc
{
    debug foo();
    bar!()();
}

void foo() @system
{
    // Just to be sure its neither @nogc, pure or nothrow
    __gshared int counter = 0;

    if (counter++)
        throw new Exception(new immutable(char)[counter]);
}

void bar()()
{
    debug {
        foo();

        auto fPtr = &S.f;
        auto f2Ptr = &f2;

        S s;
        destroy(s);

        int* ptr = cast(int*) 0;
        int[] slice = ptr[0 .. 4];
        int val = ptr[1];

        void[] bytes = slice;
        bytes[] = bytes[];

        scope int n;
        int* pn = &n;
    }
}

class S {
    void f() @safe {}
}

ref int f2(return ref int i) {
    return i;
}