aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/readmodify_structclass.d
blob: ba55e54280de1e09230f217f66548faea2331525 (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
// REQUIRED_ARGS:
shared struct S
{
    int x = 0;

    int opUnary(string s)() if (s == "++")
    {
        import core.atomic : atomicOp;
        return atomicOp!"+="(x, 1);
    }
}

shared class C
{
    int x = 0;

    int opUnary(string s)() if (s == "++")
    {
        import core.atomic : atomicOp;
        return atomicOp!"+="(x, 1);
    }
}

void main()
{
    S s;
    s++;
    shared(C) c = new C();
    c++;
}