summaryrefslogtreecommitdiff
path: root/Source/Concurrency/TypeCheck.cs
diff options
context:
space:
mode:
authorGravatar qadeer <unknown>2013-12-21 08:43:58 -0800
committerGravatar qadeer <unknown>2013-12-21 08:43:58 -0800
commitca02664886e23e4d26e9a19b07c51b82de9d9e4f (patch)
tree8c5422c52f38291627b0cc496bed48911b16c9de /Source/Concurrency/TypeCheck.cs
parent123afb33cd5137cc685bbe4faf2aab387ee0de72 (diff)
strengthened type checking w.r.t. qed vs non-qed global variables
Diffstat (limited to 'Source/Concurrency/TypeCheck.cs')
-rw-r--r--Source/Concurrency/TypeCheck.cs26
1 files changed, 20 insertions, 6 deletions
diff --git a/Source/Concurrency/TypeCheck.cs b/Source/Concurrency/TypeCheck.cs
index 0a9e6c48..91680403 100644
--- a/Source/Concurrency/TypeCheck.cs
+++ b/Source/Concurrency/TypeCheck.cs
@@ -150,11 +150,12 @@ namespace Microsoft.Boogie
CheckingContext checkingContext;
public int errorCount;
- HashSet<Variable> globalVariables;
+ HashSet<Variable> qedGlobalVariables;
int enclosingProcPhaseNum;
public Dictionary<Procedure, ActionInfo> procToActionInfo;
public Program program;
public HashSet<int> assertionPhaseNums;
+ bool inAtomicSpecification;
public void TypeCheck()
{
@@ -189,11 +190,11 @@ namespace Microsoft.Boogie
public MoverTypeChecker(Program program)
{
- this.globalVariables = new HashSet<Variable>();
+ this.qedGlobalVariables = new HashSet<Variable>();
foreach (var g in program.GlobalVariables())
{
if (QKeyValue.FindBoolAttribute(g.Attributes, "qed"))
- this.globalVariables.Add(g);
+ this.qedGlobalVariables.Add(g);
}
this.procToActionInfo = new Dictionary<Procedure, ActionInfo>();
this.assertionPhaseNums = new HashSet<int>();
@@ -201,6 +202,7 @@ namespace Microsoft.Boogie
this.checkingContext = new CheckingContext(null);
this.program = program;
this.enclosingProcPhaseNum = int.MaxValue;
+ this.inAtomicSpecification = false;
}
public override Implementation VisitImplementation(Implementation node)
{
@@ -258,16 +260,28 @@ namespace Microsoft.Boogie
}
public override Expr VisitIdentifierExpr(IdentifierExpr node)
{
- if (globalVariables.Contains(node.Decl))
+ if (node.Decl is GlobalVariable)
{
- Error(node, "Cannot access global variable");
+ if (inAtomicSpecification && !qedGlobalVariables.Contains(node.Decl))
+ {
+ Error(node, "Cannot access non-qed global variable in atomic action");
+ }
+ else if (!inAtomicSpecification && qedGlobalVariables.Contains(node.Decl))
+ {
+ Error(node, "Cannot access qed global variable in ordinary code");
+ }
}
return base.VisitIdentifierExpr(node);
}
public override Ensures VisitEnsures(Ensures ensures)
{
if (ensures.IsAtomicSpecification)
- return ensures;
+ {
+ inAtomicSpecification = true;
+ Ensures ret = base.VisitEnsures(ensures);
+ inAtomicSpecification = false;
+ return ret;
+ }
int phaseNum = QKeyValue.FindIntAttribute(ensures.Attributes, "phase", int.MaxValue);
assertionPhaseNums.Add(phaseNum);
if (phaseNum > enclosingProcPhaseNum)