summaryrefslogtreecommitdiffstats
path: root/tests/cpu-program
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cpu-program')
-rw-r--r--tests/cpu-program/pointer-basics.slang26
-rw-r--r--tests/cpu-program/pointer-basics.slang.expected6
2 files changed, 32 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
diff --git a/tests/cpu-program/pointer-basics.slang.expected b/tests/cpu-program/pointer-basics.slang.expected
new file mode 100644
index 000000000..9e97ae031
--- /dev/null
+++ b/tests/cpu-program/pointer-basics.slang.expected
@@ -0,0 +1,6 @@
+result code = 0
+standard error = {
+}
+standard output = {
+Success
+}