diff options
| author | Yong He <yonghe@outlook.com> | 2022-08-03 12:08:37 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-03 12:08:37 -0700 |
| commit | e81a5fe56f3177fc3c7040e2320ae083e3746eb7 (patch) | |
| tree | 884c15287bc10050e7883897dd266b27e62bff66 /tests/cpu-program/pointer-basics.slang | |
| parent | 260fc5fbe58f2cf976d64993054c638769bc280f (diff) | |
Basic pointer usages. (#2342)
Diffstat (limited to 'tests/cpu-program/pointer-basics.slang')
| -rw-r--r-- | tests/cpu-program/pointer-basics.slang | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/cpu-program/pointer-basics.slang b/tests/cpu-program/pointer-basics.slang new file mode 100644 index 000000000..3054cda1c --- /dev/null +++ b/tests/cpu-program/pointer-basics.slang @@ -0,0 +1,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; +}
\ No newline at end of file |
