Skip to content

Commit 9d2be71

Browse files
authored
Merge pull request #1804 from herd/fix-new-location-in-postcondition
[herd] Fix "Post-condition introduces new symbolic location" error. Symbols referred from code are part of symbols defined by a test and can appear in the post-condition. More specifically, the following test is now accepted again: ``` X86_64 A012 (* Implicit initialsation of int x=0; *) { } P0 ; movl $1,(x) ; forall [x]=1 ``` Note: the error was introduced by PR #1607 to flag missing symbols in post-condition, a very useful check. Unfortunately, the X86 and X86_64 tests generated by **diy7** were rejected. This problem is now fixed.
2 parents e9e74e8 + a173756 commit 9d2be71

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

herd/test_herd.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ module Make(A:Arch_herd.S) =
129129
| Some c -> add_constant_symbols acc c) in
130130
ConstrGen.fold_constr add_atom constr acc
131131

132+
let locs_in_ins =
133+
A.pseudo_fold
134+
(A.fold_addrs
135+
(fun v acc -> add_constant_symbols acc v))
136+
137+
let locs_in_code =
138+
List.fold_left
139+
(fun locs (_,code) -> List.fold_left locs_in_ins locs code)
140+
132141
let check_post_condition_symbols_exist test =
133142
let { MiscParser.init; condition; prog; _ } = test in
134143
let init_symbols =
@@ -137,10 +146,11 @@ module Make(A:Arch_herd.S) =
137146
let acc = add_location_symbols loc acc in
138147
add_constant_symbols acc v)
139148
StringSet.empty init in
149+
let code_symbols = locs_in_code init_symbols prog in
140150
let prog_init_symbols =
141151
List.fold_left
142152
(fun acc lbl -> StringSet.add (Label.Full.pp lbl) acc)
143-
init_symbols (A.all_labels prog) in
153+
code_symbols (A.all_labels prog) in
144154
let postcondition_symbols =
145155
add_postcondition_symbols condition StringSet.empty in
146156
let unexpected_symbols =
@@ -246,7 +256,7 @@ module Make(A:Arch_herd.S) =
246256
match v with
247257
| A.V.Val (Symbolic (Virtual {name=Symbol.Label(p,s); _}))
248258
-> begin
249-
if not (Label.Map.mem s prog) then
259+
if not (Label.Map.mem s prog) then
250260
Warn.user_error
251261
"Label %s not found on P%d, yet it is used in the initialization list" s p end
252262
| _ -> ()) init ;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
X86_64 A012
2+
(* Implicit initialsation of int x=0; *)
3+
{ }
4+
P0 ;
5+
movl $1,(x) ;
6+
forall [x]=1
7+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Test A012 Required
2+
States 1
3+
[x]=1;
4+
Ok
5+
Witnesses
6+
Positive: 1 Negative: 0
7+
Condition forall ([x]=1)
8+
Observation A012 Always 1 0
9+
Hash=3b021e40517dcff1f1cb8894d645b677
10+

0 commit comments

Comments
 (0)