diff options
author | 2009-07-15 21:03:41 +0000 | |
---|---|---|
committer | 2009-07-15 21:03:41 +0000 | |
commit | ce1c2de044c91624370411e23acab13b0381949b (patch) | |
tree | 592539996fe08050ead5ee210c973801611dde40 /Test/test16/LoopUnroll.bpl |
Initial set of files.
Diffstat (limited to 'Test/test16/LoopUnroll.bpl')
-rw-r--r-- | Test/test16/LoopUnroll.bpl | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Test/test16/LoopUnroll.bpl b/Test/test16/LoopUnroll.bpl new file mode 100644 index 00000000..83bf2686 --- /dev/null +++ b/Test/test16/LoopUnroll.bpl @@ -0,0 +1,79 @@ +procedure P()
+{
+ var x: int;
+
+ A:
+ x := 0;
+ goto B, Goner, C;
+
+ B:
+ x := 1;
+ goto D;
+
+ C:
+ x := 2;
+ goto D;
+
+ Goner:
+ x := 5;
+ assume false;
+ x := 6;
+ goto B;
+
+ D:
+ x := 3;
+ goto LoopHead;
+
+ LoopHead:
+ assert x < 100;
+ goto LoopBody, LoopDone;
+
+ LoopBody:
+ x := x + 1;
+ goto LoopHead, LoopBodyMore;
+
+ LoopBodyMore:
+ x := x + 2;
+ goto LoopHead;
+
+ LoopDone:
+ x := 88;
+ return;
+}
+
+type MyValue;
+const SpecialValue: MyValue;
+
+procedure WrongRange(a: [int]MyValue, N: int)
+ requires 0 <= N;
+{
+ var i: int, v: MyValue;
+
+ i := 1; // bad idea
+ while (i <= N) // also a bad idea
+ {
+ assert 0 <= i; // lower bounds check
+ assert i < N; // error: upper bounds check
+ v := a[i];
+ i := i + 1;
+ }
+}
+
+procedure ManyIterations(a: [int]MyValue, N: int)
+ requires 0 <= N;
+ requires a[0] != SpecialValue && a[1] != SpecialValue;
+{
+ var i: int, v: MyValue;
+
+ i := 0;
+ while (i < N)
+ {
+ assert 0 <= i; // lower bounds check
+ assert i < N; // upper bounds check
+ v := a[i];
+ assert a[i] != SpecialValue; // error: after more than 2 loop unrollings
+ i := i + 1;
+ }
+}
+
+// ERROR: /printInstrumented seems to erase filename source-location information
|