summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/runnable/testcgelem.d
blob: b5c7f7d1855fc6ad079b64bac86bb6312b1513c7 (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
/*
REQUIRED_ARGS: -mcpu=native -preview=intpromote
PERMUTE_ARGS: -O -inline -release
*/

/***
 * Do coverage testing of cgelem.d
 * Check coverage here:
 * https://codecov.io/gh/dlang/dmd/src/master/src/dmd/backend/cgelem.d
 */

import core.stdc.stdio;

template tuple(A...) { alias tuple = A; }

/*************************************************/

void test_eladdr()
{
    //  & (*p1 = e) => ((*(t = p1) = e), t)
    int i = 4;
    int* p1 = &i;
    int e = 5;
    auto x = &(*p1 = e);
    assert(i == 5);
    assert(x == p1);
}

/*************************************************/

void test_elneg()
{
    static int i = 3;
    int j = - -i;
    assert(i == j);
}

/*************************************************/

int main()
{
    test_eladdr();
    test_elneg();

    printf("Success\n");
    return 0;
}