aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/bounds.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/bounds.zc')
-rw-r--r--tests/programs/bounds.zc17
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/programs/bounds.zc b/tests/programs/bounds.zc
index 42c3997..6908683 100644
--- a/tests/programs/bounds.zc
+++ b/tests/programs/bounds.zc
@@ -1,17 +1,20 @@
+namespace;
+include rt;
+
// a +1 loop whose bound is len of the fixed array: the check is gone, the sum is not
-fn acc(fixed []int f) {
+fn acc(fixed int[?] f) {
int n = len(f), i = 0, s = 0;
for (; i < n; i += 1) f[i] = i + 1;
for (i = 0; i < n; i++) s = s + f[i];
return s;
}
-o3 fn acc3(fixed []int f) {
+o3 fn acc3(fixed int[?] f) {
int n = len(f), i = 0, s = 0;
for (; i < n; i++) f[i] = i + 1;
for (i = 0; i < n; i++) s += f[i];
return s;
}
-o3 fn small(fixed []int f) {
+o3 fn small(fixed int[?] f) {
int n = len(f), c = 0, i, j;
for (i = 2; i < n; i++) f[i] = 1;
for (i = 2; i * i < n; i++)
@@ -20,9 +23,9 @@ o3 fn small(fixed []int f) {
return c;
}
fn main() {
- fixed []int f = new(fixed []int, 10);
- fixed []int g = new(fixed []int, 20);
- put_n(acc(f)); put_c(32); put_n(acc3(f)); put_c(32); put_n(small(g)); put_c(10);
- free(d*f); free(d*g);
+ fixed int[?] f = rt.new(fixed int[?], 10);
+ fixed int[?] g = rt.new(fixed int[?], 20);
+ rt.put_n(acc(f)); rt.put_c(32); rt.put_n(acc3(f)); rt.put_c(32); rt.put_n(small(g)); rt.put_c(10);
+ rt.free(d*f); rt.free(d*g);
return 0;
}