aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/warn3882.d
blob: bf824b8c035fd757214a6fd8fad1f643cd43c146 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// PERMUTE_ARGS: -w -wi -debug
/*
TEST_OUTPUT:
---
---
*/

@safe pure nothrow void strictVoidReturn(T)(T x) {}
@safe pure nothrow void nonstrictVoidReturn(T)(ref T x) {}

void test3882()
{
    int x = 3;
    strictVoidReturn(x);
    nonstrictVoidReturn(x);
}

/******************************************/
// 12619

extern (C) @system nothrow pure void* memcpy(void* s1, in void* s2, size_t n);
// -> weakly pure

void test12619() pure
{
    ubyte[10] a, b;
    debug memcpy(a.ptr, b.ptr, 5);  // memcpy call should have side effect
}

/******************************************/
// 12760

struct S12760(T)
{
    T i;
    this(T j) inout {}
}

struct K12760
{
    S12760!int nullable;

    this(int)
    {
        nullable = 0;   // weak purity
    }
}

/******************************************/
// 12909

int f12909(immutable(int[])[int] aa) pure nothrow
{
    //aa[0] = [];   // fix for issue 13701
    return 0;
}

void test12909()
{
    immutable(int[])[int] aa;
    f12909(aa);

    // from 12910
    const(int[])[int] makeAA() { return null; }  // to make r-value
    makeAA().rehash();
}

/******************************************/
// 13899

const struct Foo13899
{
    int opApply(immutable int delegate(in ref int) pure nothrow dg) pure nothrow
    {
        return 1;
    }
}

void test13899()
{
    foreach (x; Foo13899())
    {
    }
}