aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/zc0unbounded.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 15:58:58 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 15:58:58 +0330
commitd55b5fdf92a674a6495878f97a09e95bafdcba3f (patch)
treee811149b65640a3e253e6ebdce41affddb53ac37 /tests/programs/zc0unbounded.zc
parentmerge line tables (diff)
bounds checking: port agent/bounds-checking onto main 0879d0a; unbounded main in o3call, o3 tests expect no check, boundsrules, bounds_fixed, bounds_heap and zc0unbounded tests
Diffstat (limited to 'tests/programs/zc0unbounded.zc')
-rw-r--r--tests/programs/zc0unbounded.zc16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/programs/zc0unbounded.zc b/tests/programs/zc0unbounded.zc
new file mode 100644
index 0000000..67c3ae0
--- /dev/null
+++ b/tests/programs/zc0unbounded.zc
@@ -0,0 +1,16 @@
+namespace;
+include rt;
+
+// unbounded in all three places zc0 accepts it (and ignores): the unit, a
+// function prefix and a statement. both compilers print the same.
+unbounded;
+int[4] a;
+unbounded int get(int i) { return a[i]; }
+int main() {
+ int i = 2, r = 0;
+ a[2] = 40;
+ unbounded r = get(i) + 2;
+ unbounded { r = r + a[i - 2]; }
+ rt.put_n(r); rt.put_c(10);
+ return 0;
+}