summaryrefslogtreecommitdiffstats
path: root/tests/cpu-program/pointer-basics.slang
blob: 3054cda1c70f17a4de43bf32e68f5ceea5689ae9 (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
//TEST:EXECUTABLE:
__target_intrinsic(cpp, "printf(\"%s\\n\", ($0).getBuffer())")
void writeln(String text);

public __extern_cpp int main()
{
    uint2 value;
    int *pValue = (int*)&value;
    *pValue = 1;
    (*pValue)++;
    ++pValue[0];
    ++pValue;
    *pValue = 1;
    pValue = (int *)&value;
    int64_t ptrVal = int64_t(pValue);
    pValue = (int *)ptrVal;
    if (pValue
        && pValue != nullptr
        && ptrVal != 0
        && value[0] == 3
        && pValue[1] == 1)
        writeln("Success");
    else
        writeln("Fail");
    return 0;
}