summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar qadeer <qadeer@microsoft.com>2015-04-18 17:46:27 -0700
committerGravatar qadeer <qadeer@microsoft.com>2015-04-18 17:46:27 -0700
commit6d56652342dd935f47ce5396d7f7d3a480bbb68e (patch)
tree2dfaf12a8f06dd5a8be3030567bb6413e4ca041b
parent7c950ff9a2444a4664243be1eb9fe744d1f4fc87 (diff)
patched ghost checking
-rw-r--r--Source/Concurrency/TypeCheck.cs25
-rw-r--r--Test/og/ghost.bpl27
-rw-r--r--Test/og/ghost.bpl.expect2
3 files changed, 52 insertions, 2 deletions
diff --git a/Source/Concurrency/TypeCheck.cs b/Source/Concurrency/TypeCheck.cs
index 907f7397..c407a7b9 100644
--- a/Source/Concurrency/TypeCheck.cs
+++ b/Source/Concurrency/TypeCheck.cs
@@ -474,6 +474,15 @@ namespace Microsoft.Boogie
}
if (errorCount > 0) return;
this.VisitProgram(program);
+ foreach (Procedure proc in program.Procedures)
+ {
+ if (procToActionInfo.ContainsKey(proc)) continue;
+ foreach (var ie in proc.Modifies)
+ {
+ if (!SharedVariables.Contains(ie.Decl)) continue;
+ Error(proc, "A ghost procedure must not modify a global variable with layer annotation");
+ }
+ }
if (errorCount > 0) return;
YieldTypeChecker.PerformYieldSafeCheck(this);
new LayerEraser().VisitProgram(program);
@@ -549,12 +558,24 @@ namespace Microsoft.Boogie
{
Error(node, "The callee is not available in the caller procedure");
}
+ return base.VisitCallCmd(node);
}
else
{
- Error(node, "Yielding procedure can call only a yielding procedure");
+ foreach (var ie in node.Outs)
+ {
+ if (ghostVars.Contains(ie.Decl)) continue;
+ Error(node, "The output of a ghost procedure must be assigned to a ghost variable");
+ }
+ bool savedCanAccessSharedVars = canAccessSharedVars;
+ bool savedCanAccessAuxVars = canAccessGhostVars;
+ canAccessSharedVars = true;
+ canAccessGhostVars = true;
+ var retVal = base.VisitCallCmd(node);
+ canAccessSharedVars = savedCanAccessSharedVars;
+ canAccessGhostVars = savedCanAccessAuxVars;
+ return retVal;
}
- return base.VisitCallCmd(node);
}
public override Cmd VisitParCallCmd(ParCallCmd node)
diff --git a/Test/og/ghost.bpl b/Test/og/ghost.bpl
new file mode 100644
index 00000000..ef40a232
--- /dev/null
+++ b/Test/og/ghost.bpl
@@ -0,0 +1,27 @@
+// RUN: %boogie -noinfer -typeEncoding:m -useArrayTheory "%s" > "%t"
+// RUN: %diff "%s.expect" "%t"
+var {:layer 0} x: int;
+
+procedure {:yields} {:layer 0,1} Incr();
+ensures {:right} |{ A: x := x + 1; return true; }|;
+
+procedure ghost(y: int) returns (z: int)
+requires y == 1;
+ensures z == 2;
+{
+ z := y + 1;
+}
+
+procedure {:yields} {:layer 1,2} Incr2()
+ensures {:right} |{ A: x := x + 2; return true; }|;
+{
+ var {:ghost} a: int;
+ var {:ghost} b: int;
+
+ yield;
+ call a := ghost(1);
+ assert {:layer 1} a == 2;
+ par Incr() | Incr();
+ yield;
+}
+
diff --git a/Test/og/ghost.bpl.expect b/Test/og/ghost.bpl.expect
new file mode 100644
index 00000000..41374b00
--- /dev/null
+++ b/Test/og/ghost.bpl.expect
@@ -0,0 +1,2 @@
+
+Boogie program verifier finished with 2 verified, 0 errors